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
Experienced Solver
Experienced Solver
Posts: 93
Joined: Wed Oct 28, 2015 9:48 pm

Re: help drawing this on device context

Postby Everydaydiesel » Mon Apr 23, 2018 5:29 am

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: 12685
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Postby doublemax » Mon Apr 23, 2018 5:35 am

Sorry, it's wxGLCanvas.
Use the source, Luke!

User avatar
doublemax
Moderator
Moderator
Posts: 12685
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Postby doublemax » Mon Apr 23, 2018 5:42 am

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
Experienced Solver
Experienced Solver
Posts: 93
Joined: Wed Oct 28, 2015 9:48 pm

Re: help drawing this on device context

Postby Everydaydiesel » Thu May 10, 2018 4:41 am

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: 12685
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: help drawing this on device context

Postby doublemax » Thu May 10, 2018 7:30 am

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!


Return to “C++ Development”

Who is online

Users browsing this forum: No registered users and 15 guests