A few basic OpenGL questions

Started by
2 comments, last by sinful 23 years, 2 months ago
Ok I am currently in the process of learning OpenGL, and I have a few questions about what certain things mean or what their purpose is, to better understand what is going on.. The first is, in Nehe''s tutorials, I see alot of functions declared using GLvoid. Is this necessary, or can a simple int/void be used there? gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f); Can you explain what each of the parameters in this function do? What is the range of colors in OpenGL? I don''t know if this is a stupid question but, OK, I''ve read that 0.0f is lowest value of RGB color, and 0.1f is highest value of RGB color..but lets say I wanted the color (in relation to RGB) Red = 120, Green = 40, Blue = 255? How would I translate that to all this x.xf business? I''m sure there are a few other questions I have but I won''t post them until later
Advertisement
I don''t know about the first parameter in gluPerspective but this is how its defined.

void APIENTRY gluPerspective (
GLdouble fovy,
GLdouble aspect,
GLdouble zNear,
GLdouble zFar);

Second parameter is the aspect ratio which is obtained by dividing the height and width, or you can assing some value, (GLfloat) only type casts it.

3rd and 4th is how far(into) or nearer it should be in the screen.
Hello from my world
The first parameter is the field of view (perspective angle). About RGB, 0.0 is the lowest and 1.0 is the highest, not 0.1 (probably a typo).

To get the 0-255 equivelant, just divide by 255. Nothing too hard with a tiny bit of math. I began to prefer using 0.0-1.0 after using it for a while though...


http://www.gdarchive.net/druidgames/
>but lets say I wanted the color (in relation to RGB) Red = 120, >Green = 40, Blue = 255?

You could either translate it yourself by dividing by your max value or use the OpenGL colour function:

void glColor3ub(
GLubyte red,
GLubyte green,
GLubyte blue
);

Which takes unsigned bytes as the parameters ie values in the range 0-255.

>How would I translate that to all this x.xf business?

The x.xf business is just a floating point number....the f on the end tells the compiler that you want the number to be a normal floating point number and not a double precision one....
This stops the compiler from giving the warning "conversion from ''double'' to ''float'', possible loss of data"

btw these range of colours do not apply to lights which can have values above 1.....I just noticed you can have ''dark lights'' ie lights with an intensity below zero...

>I''m sure there are a few other questions I have but I won''t post them until later

Post ''em, we like simple questions....




Game production:
Good, quick, cheap: Choose two.
Game production:Good, quick, cheap: Choose two.

This topic is closed to new replies.

Advertisement