Frame axis has the same texture as the object


So I tried to modify the cube example in Qt by transforming it into a parallelepiped and also by adding a coordinate system.
This is the function that draws the frame:

void MainWidget::draw_frame()
         glColor3f(1.0, 0.0, 0.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(4.0, 0.0, 0.0);
         // arrow
         glVertex3f(4.0, 0.0f, 0.0f);
         glVertex3f(3.75, 0.25f, 0.0f);

         glVertex3f(4.0, 0.0f, 0.0f);
         glVertex3f(3.75, -0.25f, 0.0f);
         glColor3f (0.0, 1.0, 0.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(0.0, 4.0, 0.0);
         // arrow
         glVertex3f(0.0, 4.0f, 0.0f);
         glVertex3f(0.25, 3.75f, 0.0f);

         glVertex3f(0.0, 4.0f, 0.0f);
         glVertex3f(-0.25, 3.75f, 0.0f);

         glColor3f (0.0, 0.0, 1.0);
         glVertex3f(0.0, 0.0, 0.0);
         glVertex3f(0.0, 0.0, 4.0);
         // arrow

         glVertex3f(0.0, 0.0f ,4.0f );
         glVertex3f(0.0, 0.25f ,3.75f );

         glVertex3f(0.0, 0.0f ,4.0f );
         glVertex3f(0.0, -0.25f ,3.75f );

Each axis is supposed to have a specific color ( for example x: red, y: green, z:blue).
However the axes have the same color as the object texture.
glColor3f doesn’t seem to work in this case.

Any idea on how to fix this or why does this happen ?

If GL_LIGHTING is enabled and GL_COLOR_MATERIAL is disabled, setting vertex colours does nothing; colour is determined entirely by the material and light properties. Also, if texturing is enabled that will affect the final colour.

Okay, Now I used texture->release() function to inbind the texture.
Right after I called a function I developped which is Draw_Frame to render the coordinate system. however, the frame has become black.
Should I enable GL_LIGHTING and GL_COLOR_MATERIAL right before drawing the frame ? because I tried it and unfortunately it didn’t work, the frame is still black.

But did you disable texturing?

Realistically, you need to read a book on fixed-function OpenGL (i.e. one of the earlier versions of the red book). Specifically, the parts which cover lighting and texturing. Taking some existing code and modifying it without any understanding of the parameters which control fixed-function shading isn’t a realistic approach.

The first edition is available online.

Thing is I’m not working using the opengl functions. I’m working with the QOpenGL functions in Qt.
And yes I disabled texturing using texture->release();
After doin that, the axes became all black.
Okay I will read the book.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.