glColor3f in OpenGl have little brightness
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);
c opengl freeglut opengl-1.x
|
show 1 more comment
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);
c opengl freeglut opengl-1.x
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I dont use that.
– Ana
Jan 2 at 18:53
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21
|
show 1 more comment
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);
c opengl freeglut opengl-1.x
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);
c opengl freeglut opengl-1.x
c opengl freeglut opengl-1.x
edited Jan 2 at 19:23
Ana
asked Jan 2 at 18:34
AnaAna
195
195
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I dont use that.
– Ana
Jan 2 at 18:53
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21
|
show 1 more comment
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I dont use that.
– Ana
Jan 2 at 18:53
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I dont use that.
– Ana
Jan 2 at 18:53
I dont use that.
– Ana
Jan 2 at 18:53
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21
|
show 1 more comment
2 Answers
2
active
oldest
votes
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.
glDisable(GL_LIGHTING);
and you have to enable it before you draw the geometry
glEnable(GL_LIGHTING);
The parameters to glColor3f
have to be floating point values in the range [0.0, 1.0],
glColor3f(0.0f, 1.0f, 1.0f);
in compare to glColor3ub
, where the parameters are integral values in the range [0, 255].
glColor3ub(0, 255, 255);
See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21
The commands to set RGBA colors are
void Color{34}{bsifd ubusui}( T components );
void Color{34}{bsifd ubusui}v( T components );
The Color command has two major variants:
Color3
andColor4
. The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0.
[...] Versions of the Color and SecondaryColor commands that take floating-point
values accept values nominally between 0.0 and 1.0.
[...]
GL Type Conversion
ubyte c/(2^8 − 1)
byte (2c + 1)/(2^8 − 1)
ushort c/(2 16 − 1)
short (2c + 1)/(2^16 − 1)
uint c/(2^32 − 1)
int (2c + 1)/(2^32 − 1)
float c
double c
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
add a comment |
Do you use a texture somewhere? If so, try disabling texturing before drawing the other thing.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011452%2fglcolor3f-in-opengl-have-little-brightness%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
glDisable(GL_LIGHTING);
and you have to enable it before you draw the geometry
glEnable(GL_LIGHTING);
The parameters to glColor3f
have to be floating point values in the range [0.0, 1.0],
glColor3f(0.0f, 1.0f, 1.0f);
in compare to glColor3ub
, where the parameters are integral values in the range [0, 255].
glColor3ub(0, 255, 255);
See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21
The commands to set RGBA colors are
void Color{34}{bsifd ubusui}( T components );
void Color{34}{bsifd ubusui}v( T components );
The Color command has two major variants:
Color3
andColor4
. The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0.
[...] Versions of the Color and SecondaryColor commands that take floating-point
values accept values nominally between 0.0 and 1.0.
[...]
GL Type Conversion
ubyte c/(2^8 − 1)
byte (2c + 1)/(2^8 − 1)
ushort c/(2 16 − 1)
short (2c + 1)/(2^16 − 1)
uint c/(2^32 − 1)
int (2c + 1)/(2^32 − 1)
float c
double c
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
add a comment |
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.
glDisable(GL_LIGHTING);
and you have to enable it before you draw the geometry
glEnable(GL_LIGHTING);
The parameters to glColor3f
have to be floating point values in the range [0.0, 1.0],
glColor3f(0.0f, 1.0f, 1.0f);
in compare to glColor3ub
, where the parameters are integral values in the range [0, 255].
glColor3ub(0, 255, 255);
See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21
The commands to set RGBA colors are
void Color{34}{bsifd ubusui}( T components );
void Color{34}{bsifd ubusui}v( T components );
The Color command has two major variants:
Color3
andColor4
. The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0.
[...] Versions of the Color and SecondaryColor commands that take floating-point
values accept values nominally between 0.0 and 1.0.
[...]
GL Type Conversion
ubyte c/(2^8 − 1)
byte (2c + 1)/(2^8 − 1)
ushort c/(2 16 − 1)
short (2c + 1)/(2^16 − 1)
uint c/(2^32 − 1)
int (2c + 1)/(2^32 − 1)
float c
double c
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
add a comment |
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.
glDisable(GL_LIGHTING);
and you have to enable it before you draw the geometry
glEnable(GL_LIGHTING);
The parameters to glColor3f
have to be floating point values in the range [0.0, 1.0],
glColor3f(0.0f, 1.0f, 1.0f);
in compare to glColor3ub
, where the parameters are integral values in the range [0, 255].
glColor3ub(0, 255, 255);
See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21
The commands to set RGBA colors are
void Color{34}{bsifd ubusui}( T components );
void Color{34}{bsifd ubusui}v( T components );
The Color command has two major variants:
Color3
andColor4
. The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0.
[...] Versions of the Color and SecondaryColor commands that take floating-point
values accept values nominally between 0.0 and 1.0.
[...]
GL Type Conversion
ubyte c/(2^8 − 1)
byte (2c + 1)/(2^8 − 1)
ushort c/(2 16 − 1)
short (2c + 1)/(2^16 − 1)
uint c/(2^32 − 1)
int (2c + 1)/(2^32 − 1)
float c
double c
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.
glDisable(GL_LIGHTING);
and you have to enable it before you draw the geometry
glEnable(GL_LIGHTING);
The parameters to glColor3f
have to be floating point values in the range [0.0, 1.0],
glColor3f(0.0f, 1.0f, 1.0f);
in compare to glColor3ub
, where the parameters are integral values in the range [0, 255].
glColor3ub(0, 255, 255);
See OpenGL Specification (Version 2.0) - 2.7. VERTEX SPECIFICATION; page 21
The commands to set RGBA colors are
void Color{34}{bsifd ubusui}( T components );
void Color{34}{bsifd ubusui}v( T components );
The Color command has two major variants:
Color3
andColor4
. The four value versions set all four values. The three value versions set R, G, and B to the provided values; A is set to 1.0.
[...] Versions of the Color and SecondaryColor commands that take floating-point
values accept values nominally between 0.0 and 1.0.
[...]
GL Type Conversion
ubyte c/(2^8 − 1)
byte (2c + 1)/(2^8 − 1)
ushort c/(2 16 − 1)
short (2c + 1)/(2^16 − 1)
uint c/(2^32 − 1)
int (2c + 1)/(2^32 − 1)
float c
double c
edited Jan 2 at 19:38
answered Jan 2 at 18:41


Rabbid76Rabbid76
42.5k123354
42.5k123354
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
add a comment |
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
I try this but the result is the same
– Ana
Jan 2 at 18:51
I try this but the result is the same
– Ana
Jan 2 at 18:51
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
Rabbid your comment for Disable and Enable function was the solution THANKS YOUU!!
– Ana
Jan 2 at 19:40
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
but your comment in my question were delete, but I dont do that. I try to found your comment but doesnt appear.
– Ana
Jan 2 at 19:44
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
@Ana I extended the answer. I deleted the comment and added the comment to the answer (at the begin of the answer).
– Rabbid76
Jan 2 at 19:45
add a comment |
Do you use a texture somewhere? If so, try disabling texturing before drawing the other thing.
add a comment |
Do you use a texture somewhere? If so, try disabling texturing before drawing the other thing.
add a comment |
Do you use a texture somewhere? If so, try disabling texturing before drawing the other thing.
Do you use a texture somewhere? If so, try disabling texturing before drawing the other thing.
answered Jan 2 at 19:30


datenwolfdatenwolf
134k10135238
134k10135238
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011452%2fglcolor3f-in-opengl-have-little-brightness%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I try to do this, but the result is the same. The brightness is so low, nearly to the black.
– Ana
Jan 2 at 18:44
I dont use that.
– Ana
Jan 2 at 18:53
Do you draw your text before or after drawing the model? Did you try swapping the order?
– n0rd
Jan 2 at 19:05
after the model, but if i draw the model after the texts the result is the same
– Ana
Jan 2 at 19:09
I have this GLfloat lightpos = { 5.0, 15., 5., 0. }; glLightfv(GL_LIGHT0, GL_POSITION, lightpos); Maybe, this is the problem?
– Ana
Jan 2 at 19:21