Menu

OpenGL support is not valid

Help
Liam
2012-09-12
2012-10-16
  • Liam

    Liam - 2012-09-12

    I tried the latest mathgl-2.0.3. Drawing with OpenGL is not working both on
    Linux and Windows. The screen is blank after drawing.

    I tracked down the code and found:

    1. opengl.h

    void SetQuality(int =0) { Quality=2; }

    1. Canvas.cpp

    define MGL_LINE_PLOT if(Quality&4) line_draw(p1,p2,&dd);else \

    { mglPrim a(1); a.n3=PDef; a.s = pPos; \
    a.n1 = p1; a.n2 = p2; a.w = pw; add_prim(a); }

    If the Quality forced to 2, then the virtual function line_draw() is never
    called. I changed to 4, and really debugged into the opengl drawing code. but
    still it doesn't work.

    Can anyone correct me?? Thanks!

     
  • Alexey Balakin

    Alexey Balakin - 2012-09-13

    Hi,

    In v.2.* all drawing take place in Finish() function. There is the only
    exception -- Quality&4!=0. Usually Finish() function is called internally each
    time when you save picture, update it a window or access to RGB values. So,
    you don't need to call Finish() until you are using pure OpenGL mode.

    Unfortunately, I forgot to provide a public interface for this function. I
    just do it in SVN rev.547. Thank you for the error.

    So, you can update from SVN and add call gr->Finish() at the end of plotting
    function.

    Or you can use following hint right now

    mglCanvas *g=dynamic_cast<mglCanvas*>(gr->Self());
    if(g) g->Finish();
    

    But keep in mind that this hint is not guarantee to be binary compatible with
    further MathGL version.

     
  • Liam

    Liam - 2012-09-13

    Thanks abalakin

    I make the pure OpenGL mode work with MFC.

    I found a strange thing. The code " gr->Label(’y’,"axis 1",0); " draws nothing
    to the screen in OpenGL mode. So I cannot add label the axis. However, the
    code " gr->Puts(mglPoint(0,1.2),"Normal scale"); " works.

    Could you verify that?

     
  • Alexey Balakin

    Alexey Balakin - 2012-09-20

    Yes, there is a problem with text drawing in OpenGL mode. I'll try to fix it.
    Thank you

     
  • Alexey Balakin

    Alexey Balakin - 2012-09-21

    I hope that I fix it in svn rev.553.

     
  • Liam

    Liam - 2012-09-21

    You'r so nice.

    The reason I prefer to using OpenGL is the drawing is much faster. Someone
    firstly draws to a bitmap in memory, then copies the bitmap to screen. It
    works fine, but consumes a lot of CPU time. So the frame rate for animation is
    not good enough.

     

Log in to post a comment.

MongoDB Logo MongoDB