I have a problem with my code in OpenGl
I need to do a game engine.
I use freeglut library.
I did this practise with old Visual Studio versions and I don't have this problem. But with the Visual Studio 2017 the attribute glColor3f
is showed with little brightness. Why?
This is the code that I use for to show the texts:
char instrucciones3[100];
sprintf_s(instrucciones3, "PULSA 'ESC' SI QUIERES SALIR");
char *res4 = instrucciones3;
glColor3f(0.0f, 1.0f, 1.0f); //This is the problem, I dont have alpha but the brightness is low.
glRasterPos3f(1.0f, 5.0f, 0.0f);
drawString(res4);
char instrucciones2[100];
sprintf_s(instrucciones2, "PULSA 'H' PARA COMENZAR PARTIDA ");
char *res3 = instrucciones2;
glColor3f(0.0f, 1.0f, 1.0f);
glRasterPos3f(-10.0f, 5.0f, 0.0f);
drawString(res3);
Update:
The brightness is so low, but the model is good. I put glColor3f(0.0f, 1.0f, 1.0f);
in the new code but the result is the same.
Update2 This is my displayMe func:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0, 3, 15, 0, 0, 0, 0, 1, 0);
glRotatef(yaw, 0.0, 1.0, 0.0);
glRotatef(pitch, 1.0, 0.0, 0.0);
glRotatef(roll, 0.0, 0.0, 1.0);
GLfloat lightpos[] = { 5.0, 15., 5., 0. };
glLightfv(GL_LIGHT0, GL_POSITION, lightpos);
The fixed function light model is applied on the text, too. This will cause arbitrary results, dependent on the current light settings ans current normal vector attribute. You have to disable lighting before you draw the text.
and you have to enable it before you draw the geometry
The parameters to
glColor3f
have to be floating point values in the range [0.0, 1.0],in compare to
glColor3ub
, where the parameters are integral values in the range [0, 255].See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21