Hi, I’m new to OpenGL.
I have a problem: usig c++ Builder 5.0, I can’t draw lines unsing:
glColor3f(1.0f, 0.0f, 0.0f);
What I have to do?
(I’m sorry for my English, but I am Italian)
Nothing wrong with that piece of code, so you have to show more. How do you set up the window? The modelview and projection matrix? Any other states enabled?
Getting a line on the screen involves more than just sending the vertices.
Here the code:
void __fastcall TForm1::OpenGLPanel1Paint(TObject *Sender)
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
//vertex 1/2 for one line
glColor3f( 0.0f, 1.0f, 0.0f);
//vertex 2/2 for one line
void __fastcall TForm1::OpenGLPanel1Resize(TObject *Sender)
void __fastcall TForm1::OpenGLPanel1Init(TObject *Sender)
glClearColor(1.0, 1.0, 1.0, 0.0);
And where do you create the rendering context? More than what you posted is required to get an OpenGL program running.
I have downloaded the OpenGL_DP libraries form the net, it creates an OpenGLPanel and now on you can draw anything. For example the same code I’ve posted with
glBegin(GL_POLYGON) works very well. It is only GL_LINES that doesn’t work.
Ok, I suppose that library takes care of the rendering context and all that stuff then.
If you add a third vertex, and replace GL_LINES with GL_POLYGON, does it work then? Or do you mean that another program but with similar code works?
What happens if you don’t change line width and don’t enable line smooth?
Now it works! I don’t know why, but it works.