help drawing this on device context

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Everydaydiesel
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Oct 28, 2015 9:48 pm

Re: help drawing this on device context

Post by Everydaydiesel »

Maybe I should have done that from the start? When I search google and docs.wxwidgets.org i dont see any wxGLPanel documentation? Do you know how I would do this?

Drawing with opengl seems to be pretty straight foward using glVertex2f
https://www.ntu.edu.sg/home/ehchua/prog ... ction.html
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Post by doublemax »

Sorry, it's wxGLCanvas.
Use the source, Luke!
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Post by doublemax »

Drawing with opengl seems to be pretty straight foward using glVertex2f
That depends on which drawing operations you need. E.g. there is no function to draw text in OpenGL. So you need to find some code that does this for you.

I just remembered this:
viewtopic.php?p=96261

It's pretty old, but maybe it still works.
Use the source, Luke!
Everydaydiesel
Earned some good credits
Earned some good credits
Posts: 125
Joined: Wed Oct 28, 2015 9:48 pm

Re: help drawing this on device context

Post by Everydaydiesel »

So I was able to get AA to work properly but not on this code..

code from other thread

Code: Select all

    wxPaintDC pdc(this);

#if wxUSE_GRAPHICS_CONTEXT
     wxGCDC gdc( pdc ) ;
    wxDC &dc = m_useContext ? (wxDC&) gdc : (wxDC&) pdc ;
#else
    wxDC &dc = pdc ;
#endif

    PrepareDC(dc);

my code using wxMemoryDC (drawing to a buffer/wxbitmap and then rendering it to screen)

Code: Select all

    wxMemoryDC pdc;
    bool m_useContext = true;
    wxGCDC gdc( pdc ) ;         // this gives a core dump
    wxMemoryDC &dc = m_useContext ? (wxMemoryDC&) gdc : (wxMemoryDC&) pdc ;
Can someone please tell me why this causes a core dump? Casting problem?
User avatar
doublemax
Moderator
Moderator
Posts: 19159
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Post by doublemax »

Code: Select all

wxMemoryDC pdc;
bool m_useContext = true;

// wxMemoryDC pdc is not initialized with a bitmap at this point
wxGCDC gdc( pdc ) ;         // this gives a core dump   

// this should be wxDC &dc like in the sample. gdc is not a wxMemoryDC
wxMemoryDC &dc = m_useContext ? (wxMemoryDC&) gdc : (wxMemoryDC&) pdc ;
Use the source, Luke!
Post Reply