c++ - controlling paintGL method - How to decide what to paint? -


i want control paintgl method keypress-event. aim show additional point pushing return. in other words: have painted nice background scene , want push return (in lineedit) , there appears red point in front of shown background.

//mainwindow.cpp

mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) {     ui->setupui(this);     glwidget = new glwidget;     connect(ui->lineedit,   signal(returnpressed()),    glwidget, slot (set_draw())); } 

//glwidget.h

#ifndef glwidget_h #define glwidget_h  #include <qglwidget> #include <qmessagebox> #include "mainwindow.h" #include "cstdio"   class mainwindow;  class glwidget : public qglwidget {  q_object  mainwindow *mymainwindow;      public:     glwidget(qwidget *parent = 0);     //~glwidget;      int draw;      void initializegl();     void paintgl();     void resizegl(int w, int h);  public slots:     void set_draw();  }; #endif // glwidget_h 

//glwidget.cpp

glwidget::glwidget(qwidget *parent) : qglwidget(parent) {     draw = 0; } //------------- void glwidget::set_draw()  //this slot activated pushing return { draw = 1; updategl(); //updating paintgl... } //------------- void glwidget::paintgl() {     swapbuffers();     glclear(gl_color_buffer_bit);  /* drawing lot of stuff*/      if( draw == 1 )     { /*the following messagebox shown @ screen*/ qmessagebox* box = new qmessagebox(); box->settext("bert"); box->show();  /*this big red point not shown @ screen*/         glpointsize(30);         glbegin(gl_points);             glcolor3f(1.0, 0.0, 0.0);             glvertex3f(45,45,0);         glend();     }  } 

can explain, why not working? red point not appear... value of int draw influenced paintgl method?

in opengl redraw whole scene. store additional point in array. when drawing iterate on array , draw points according array's content.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -