Archived

This topic is now archived and is closed to further replies.

orcblood

Adding points "on click"

Recommended Posts

Im attempting to create some vertex points once the left mouse button has been pressed in my program. The program compiles nad runs fine, however, I never actually SEE the points... This is strange, however, prehaps someone could tell me why (I probably heven''t throught of something).

bool lmc; // left mouse click
bool lm_click; // left mouse press

case WM_LBUTTONDOWN:
        {

             lmc=TRUE;
             lm_click=!lm_click;

             if(!lm_click)
             {
                   glColor3f(1.0f, 1.0f, 1.0f);
                   glVertex3f(0.1f, 0.0f, 0.0f);
             }

        }

 
Im probably missing some major part of the code, prehaps I need to declair a variable for if the left mouse has been pressed that would go into the int DrawGLScene section of the program''s code?

Share this post


Link to post
Share on other sites
glVertex etc is used for drawing the point, and must be within glBegin/glEnd for a start.

Next, it draws the vertex ONCE. Thats all. So if you want to be able to see it in more than one frame, you''d better call glVertex for each point, each frame.

So yes, you''ll need a variable to store the vertex or list of vertices created with the mouse click and then go through this list and draw all the verts everyt frame.

Share this post


Link to post
Share on other sites
you have to call glVertex(...) between calls to glBegin() and glEnd. it would probably be better to add the points to an array (or std::vector) and then have a function that you call once per frame that goes through the list and draws all points.

edit: beat me to it..

[edited by - necromancer_df on April 3, 2004 9:41:11 AM]

Share this post


Link to post
Share on other sites