PDA

View Full Version : No color shown in this simple code?



reader1
04-09-2015, 04:37 AM
glBegin(GL_QUADS);
glColor3f(0.0,1.0,1.0);
glVertex2f(0.0,-0.15);
glVertex2f(0.0, 0.35);
glVertex2f(0.35,0.35);
glVertex2f(0.35,-0.15);
glEnd();
glFlush();
This is a simple code to draw a quad, I want it is a blue one, but no blue color appears, what's matter?

Agent D
04-09-2015, 05:04 AM
Do you mean that nothing is drawn or that the color is not the one you want?

Also, (0.0,1.0,1.0) is more turquoise than blue.

reader1
04-09-2015, 05:40 AM
Do you mean that nothing is drawn or that the color is not the one you want?

Also, (0.0,1.0,1.0) is more turquoise than blue.
Just no color I want, it is (0.0, 0.0, 1.0), not (0,1,1).

reader1
04-09-2015, 07:19 AM
using version3.3, do the glbegin and glend still valid?

Alfonse Reinheart
04-09-2015, 01:17 PM
using version3.3, do the glbegin and glend still valid?

Assuming you created a compatibility context (https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts), yes.

reader1
04-09-2015, 04:54 PM
Assuming you created a compatibility context (https://www.opengl.org/wiki/Core_And_Compatibility_in_Contexts), yes.
then, what's matter with the color shown?

Alfonse Reinheart
04-09-2015, 05:03 PM
If changing the value you pass for glColor gets you a different color, then it seems clear that the problem is not with the code you've shown. Perhaps you could try playing with the given color and seeing if you can determine some kind of pattern as to which colors you get.

Also, you said, "Just no color I want, it is (0.0, 0.0, 1.0), not (0,1,1). ". How do you know that the color you're getting is (0, 0, 1) rather than (0, 1, 1)? That is, what are you comparing the color you get to, such that you know that it's not the right color?

reader1
04-09-2015, 06:48 PM
Also, you said, "Just no color I want, it is (0.0, 0.0, 1.0), not (0,1,1). ". How do you know that the color you're getting is (0, 0, 1) rather than (0, 1, 1)? That is, what are you comparing the color you get to, such that you know that it's not the right color?
is Not how know, I enforce it to show(or render) in such color. I assign it this color. or toher color as well.

That's very simple, just see the result from exacutable file. run it.

reader1
04-09-2015, 06:57 PM
If changing the value you pass for glColor gets you a different color, then it seems clear that the problem is not with the code you've shown. Perhaps you could try playing with the given color and seeing if you can determine some kind of pattern as to which colors you get.
We can easily think of that naturally. as I said, no matter how I change the value of color, it obstinately persist one color.
but when use default redering pipeline, it can show graduate color inside.

reader1
04-09-2015, 07:00 PM
According to books, to guides, to all or any docs, this is absolute standard written.

Alfonse Reinheart
04-09-2015, 07:56 PM
We can easily think of that naturally. as I said, no matter how I change the value of color, it obstinately persist one color.
but when use default redering pipeline, it can show graduate color inside.

I don't know what you mean by "show graduate color inside" (I'm guessing you're referring to a "gradient" of colors). But you spoke of the "default redering[sic] pipeline". Does that mean that you're not using the "default redering pipeline" normally? What do you mean by the "default" pipeline; are you referring to the fixed function (https://www.opengl.org/wiki/Fixed_Function_Pipeline) pipeline? Does that mean that your example code was originally using shaders?

reader1
04-09-2015, 08:10 PM
I don't know what you mean by "show graduate color inside" (I'm guessing you're referring to a "gradient" of colors). But you spoke of the "default redering[sic] pipeline". Does that mean that you're not using the "default redering pipeline" normally? What do you mean by the "default" pipeline; are you referring to the fixed function (https://www.opengl.org/wiki/Fixed_Function_Pipeline) pipeline? Does that mean that your example code was originally using shaders?

So it is, it's gradient. and rendering. I think a native-speaking eng can recognize it easily and promptly.

reader1
04-09-2015, 08:17 PM
What do you mean by the "default" pipeline; are you referring to the fixed function pipeline? Does that mean that your example code was originally using shaders?
What it is uniform shader or fixed is not problem. I havn't yet use any functional glsl.
If I draw the triangle by shader(vao,vbo0, it has default gradient color inside(the triangle). but when I draw the triangle like above code, its color can not be changed.

Alfonse Reinheart
04-09-2015, 10:22 PM
After reading through some of the earlier posts in this thread, I think I came across a statement that shed some light on the problem:


it obstinately persist one color.

Is your problem that you're not getting the color you want, or that there is no color gradient? (these are in fact two different problems).

If so, first, you should have said that earlier; it shouldn't have taken you 9 posts before the word "gradient" came up. Second, why would you expect to see a color gradient? To get the "default gradient color inside(the triangle)", you had to pass an array of colors along with an array of positions. Your fixed-function quad has 4 positions, but only 1 color.

If you want a color gradient, then you need to provide multiple colors to be interpolated across. One for each vertex. Just like your shader example.

reader1
04-10-2015, 01:15 AM
After reading through some of the earlier posts in this thread, I think I came across a statement that shed some light on the problem:

Is your problem that you're not getting the color you want, or that there is no color gradient? (these are in fact two different problems).

If so, first, you should have said that earlier; it shouldn't have taken you 9 posts before the word "gradient" came up. Second, why would you expect to see a color gradient? To get the "default gradient color inside(the triangle)", you had to pass an array of colors along with an array of positions. Your fixed-function quad has 4 positions, but only 1 color.

If you want a color gradient, then you need to provide multiple colors to be interpolated across. One for each vertex. Just like your shader example.
I wonder if you are vague, or you intend to mislead the content, the last thing I 'll see.

you needn't waste either your time or my time at that meaningfulless trick.
of cuase you can keep picking up interesting letters or words to confuse the thread. and show how your eng is good. and even choose sentences to analysis from grammar or custom, that is really not pure englsih. Indeed, I like to hear that and read your conclusion.

Well, the problem is how to get a different color for different objects in a code?(blue or cyn or otherwise) if you can go further more to make two different complex gradient triangles or quads, that will be aslo wecome.

reader1
04-10-2015, 01:26 AM
You'd better be pleased with finding why there is no 's followed the persist? that is very important to taunt.

reader1
04-10-2015, 02:39 AM
I get it. it's issue of switcher. Now the beautiful graphics with a riot of colors are shown on the screen.

not bad to argue the off topic with one.