i wanted to create a line that is thick using OpenGL library in c++ but it is not working. i tried this code:
glBegin(GL_LINES);
glLineWidth(3);
glVertex2f(-0.7f, -1.0f);
glVertex2f(-0.7f, 1.0f);
glEnd();
is there something wrong here?
Note that rendering with glBegin/glEnd sequences and also glLineWidth is deprecated. See OpenGL Line Width for a solution using "modern" OpenGL.
It is not allowed to call glLineWidth with in a glBegin/glEnd sequence. Set the line width before:
glLineWidth(3);
glBegin(GL_LINES);
glVertex2f(-0.7f, -1.0f);
glVertex2f(-0.7f, 1.0f);
glEnd();
Once drawing of primitives was started by glBegin it is only allowed to specify vertex coordinates (glVertex) and change attributes (e.g. glColor, glTexCoord, etc.), till the drawn is ended (glEnd).
All other instruction will be ignored and cause a GL_INVALID_OPERATION error, which can be get by glGetError.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With