I think part of your problem is structure of your openGL program; I am not a big on object-oriented programming but will try to give you an example of structure for drawing and you my have to translate a little more to OOP.
Also you must understand that you have to redraw all the objects on the screen every time you move an object. You should not be translating your object on a mouse button press, but changing a variable. Then during the Drawing of the screen, the variable change will then will make the line position updated.
Let’s create a few basic program objects:
- opengl initializes screen: Cview::Init_Opengl()
- Draw objects: Cview: :Draw_Screen()
- Draw a object: Cview: :Draw_Object()
- opengl object control: Cview::Object_Control()
Let’s create a basic object storage variable:
// Do all screen processing here.
for(x=0; x < object_total; x++) // process all the object on our screen.
Draw_Object( My_Object[x] );
Draw_Object( *My_Object )
glColor3f(My_Object.r, My_Object.g, My_Object.b );
glTranslate(My_Object.x, My_Object.y, My_Object.z );
// Process Object data here.
if ( On_left_button ) Update_Object( My_Object ); Change objects variables here.
Originally posted by aus79er:
I have a simple draw line code …
I am drawing a line in VC++ MFC application.
glBegin ( GL_LINES);
glColor3f ( 0.0f, 1.0f, 1.0f ) ;
Now I am able to see the line.But the line is going out of the screen.
So what I want to do is to scale the screen so that I can see the whole line falling within the screen.
So what I thought that by translating in Z direction I will be able to see the whole line…
void CSim_4_26_02View::OnLButtonDblClk(UINT nFlags, CPoint point)
// TODO: Add your message handler code here and/or call default
Now whenever I click on the screen the line diappears…
It works when i translate only in x direction or y…
I have also tried changing the Z value of the translate function from + to - but to no avail…
So when i translate my line in z direction regardless of direction it disappears…
Can any body help me with it…what am i doing wrong…
Thanks in advance
[This message has been edited by nexusone (edited 05-15-2002).]