Colors

Started by
2 comments, last by TGA 17 years, 1 month ago
Hello! I am new on OpenGL and I have a stressfull problem: So i learned to created basic shapes(triangles and quads), but I am really confused by one thing: let's say I created a quad and I want to color it rgb(177,222,251). How can I find this color in "OpenGL coordinates", too look something like this: glColor3f(0.5f,0.5f,1.0f);"
Advertisement
If you already have the colors in the range from 0 to 255, use the function that takes color values in that range; glColor3ub. If you insist on using the 0 to 1 range functions anyway, just divide by 255.
This helped me very much. Thanks! But now I have another problem(because I don't really understand this 0.0->1.0f coordinates system). How can I do something like:
glLoadIdentity();glTranslatef(-14,0,15); //moves 14 pixels to left, 15 pixels into the screen instead ofglTranslatef(-1.5f,0.0f,-6.0f);	// Move left 1.5 Units And Into The Screen 6.0ORto do something like glBegin(GL_TRIANGLES);								glVertex3f(14, 12, 19);		glVertex3f(15,12, 35);				glVertex3f(11,16, 61);	glEnd();	instead ofglBegin(GL_TRIANGLES);								glVertex3f( 0.0f, 1.0f, 0.0f);						glVertex3f(-1.0f,-1.0f, 0.0f);				glVertex3f( 1.0f,-1.0f, 0.0f);			glEnd();	

If this can't be done, can anyone explain how to mathematically calculate these thins...
I hope you understand what i want to say...
Firstly, I'm relatively new to this, so this post might be wrong...

Firstly, 0.0-1.0 is only for colours, when using floats (or doubles?). They correspond to a range of 0-255 when using bits. For transformations the values aren't clamped, and a unit is an arbitary measure - you could use one unit to represent 1mm or 1km - as long as everything uses the same scale it'll look right.

Now it seems to me you want to work with one unit being one pixel. This doesn't really work in 3D space, however it does work in 2D space, using the glOrtho(...) command as your perspective matrix, with the height and width being the pixel height and width of the screen. You can do depth by using the z-cordinate, but there will be no perspective effects (really just used to do depth tests).

This topic is closed to new replies.

Advertisement