OpenGl questions

This is a discussion on OpenGl questions within the Windows Programming forums, part of the Platform Specific Boards category; Well I have a lot of OpenGl questions so I hope someone can help me out here. Oh and Iím ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    51

    OpenGl questions

    Well I have a lot of OpenGl questions so I hope someone can help me out here. Oh and Iím learning OpenGl thru http://nehe.gamedev.net/ if that should make a difference

    1. Can the lighting be changed at all after it was initialized? Like the position, color etc.

    2. Using glColor3f(1.0f,0.0f,0.0f); how would I limit to what it affects? For example
    Code:
    int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
    	glLoadIdentity();									// Reset The View
    	glTranslatef(0.0f,0.0f,-10.0f);
    	glBindTexture(GL_TEXTURE_2D, texture[0]);				// Select A Texture Based On filter
    		glBegin(GL_QUADS);							// Start Drawing Quads
    		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 1 (Front)
    		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 2 (Front)
    		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Front)
    		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 4 (Front)
    	glEnd();								// Done Drawing Quads
    	glColor3f(1.0f,0.0f,0.0f);
    	glPrint("NAH A HSJKLTSRAO!!#@#$@%)$_");										// Draw A Skull And Crossbones Symbol
    		return TRUE;										// Keep Going
    }
    I don't understand why the glColor3f affects the quad when its after it...

    3. Using glNormal3f( 0.0f, 0.0f, 1.0f); it finds out where the center of the object is by itself? What if itís on a slant like a pyramid would it matter? Or you accidentally go over like if the object is located at 0.0f,0.0f,0.0f,1.0f and you use glNormal3f( 0.0f, 0.0f, 2.0f);

    4. How does glColor4ub work? I never really understood the mechanicsÖ

    5. Does minimapping take more cpu power or less then linear mapping?

    6. Also how would you load multiple image files/textures? Or reload them later in the programming for example you walk through a portal and now your in a new town etc.

    7. Last thing how do transparent images work in Opengl? I need to be able to make some parts of an image transparent but Iím not sure how to go about doing this.

    8. Know any good books to learn opengl?

  2. #2
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    Quote Originally Posted by Shadowwoelf View Post
    1. Can the lighting be changed at all after it was initialized? Like the position, color etc.
    Absolutely.

    Quote Originally Posted by Shadowwoelf View Post
    2. Using glColor3f(1.0f,0.0f,0.0f); how would I limit to what it affects? For example
    Code:
    int DrawGLScene(GLvoid)									// Here's Where We Do All The Drawing
    {
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);	// Clear The Screen And The Depth Buffer
    	glLoadIdentity();									// Reset The View
    	glTranslatef(0.0f,0.0f,-10.0f);
    	glBindTexture(GL_TEXTURE_2D, texture[0]);				// Select A Texture Based On filter
    		glBegin(GL_QUADS);							// Start Drawing Quads
    		glTexCoord2f(0.0f, 0.0f); glVertex3f(-1.0f, -1.0f,  1.0f);	// Point 1 (Front)
    		glTexCoord2f(1.0f, 0.0f); glVertex3f( 1.0f, -1.0f,  1.0f);	// Point 2 (Front)
    		glTexCoord2f(1.0f, 1.0f); glVertex3f( 1.0f,  1.0f,  1.0f);	// Point 3 (Front)
    		glTexCoord2f(0.0f, 1.0f); glVertex3f(-1.0f,  1.0f,  1.0f);	// Point 4 (Front)
    	glEnd();								// Done Drawing Quads
    	glColor3f(1.0f,0.0f,0.0f);
    	glPrint("NAH A HSJKLTSRAO!!#@#$@%)$_");										// Draw A Skull And Crossbones Symbol
    		return TRUE;										// Keep Going
    }
    I don't understand why the glColor3f affects the quad when its after it...
    The color remains set to red until you change it to something else, and you're never changing it to anything else.

    Quote Originally Posted by Shadowwoelf View Post
    3. Using glNormal3f( 0.0f, 0.0f, 1.0f); it finds out where the center of the object is by itself? What if itís on a slant like a pyramid would it matter? Or you accidentally go over like if the object is located at 0.0f,0.0f,0.0f,1.0f and you use glNormal3f( 0.0f, 0.0f, 2.0f);
    To the best of my knowledge, glNormal just indicates which direction is perpendicular to the polygon. This allows the light to reflect properly. I don't do much lighting work, so I may be wrong about this.

    Quote Originally Posted by Shadowwoelf View Post
    4. How does glColor4ub work? I never really understood the mechanicsÖ
    Hmm, I'm not familiar with the form. I only use glColor4f and glColor4fv. I'd have to look that up somewhere.

    Quote Originally Posted by Shadowwoelf View Post
    5. Does minimapping take more cpu power or less then linear mapping?
    I believe linear is the fastest, but I may be wrong.

    Quote Originally Posted by Shadowwoelf View Post
    6. Also how would you load multiple image files/textures? Or reload them later in the programming for example you walk through a portal and now your in a new town etc.
    glGenTextures creates textures, glDeleteTextures destroys them. In combination, these will handle everything.

    Quote Originally Posted by Shadowwoelf View Post
    7. Last thing how do transparent images work in Opengl? I need to be able to make some parts of an image transparent but Iím not sure how to go about doing this.
    You'll need an image format that supports transparency, and then you need to set up alpha blending on the OpenGL end. I believe NeHe has a tutorial on this.

    Quote Originally Posted by Shadowwoelf View Post
    8. Know any good books to learn opengl?
    The red book (OpenGL Programming Guide) is fantastic. The blue book (OpenGL Reference) is even better once you get a basic handle on things.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Posts
    51
    Thanks AverageSoftware, I found the redbook on google too. I was wondering though for my second question how do you set the color back to neutral? Like I don't want to color my quad at all.

    *edit* Well I just read the first page of theredbook and I'm officially lost just to make sure this is the right website right?

    http://fly.cc.fer.hr/~unreal/theredbook/chapter01.html

    Also to have it not change my image I added this before I drew my quad

    glColor4f(1.0f,1.0f,1.0f,0.0f);
    Last edited by Shadowwoelf; 06-20-2007 at 05:56 PM.

  4. #4
    Massively Single Player AverageSoftware's Avatar
    Join Date
    May 2007
    Location
    Buffalo, NY
    Posts
    141
    Quote Originally Posted by Shadowwoelf View Post
    Thanks AverageSoftware, I found the redbook on google too. I was wondering though for my second question how do you set the color back to neutral? Like I don't want to color my quad at all.
    If you're texture mapping, you probably want to set the color to white right before you draw the quad, that is glColor3f(1.0, 1.0, 1.0); right before the glBegin(). Drawing a texture in white is "normal." Using different colors will tint the texture, as you probably noticed.

    Incidentally, glColor3ub takes unsigned bytes as parameters. I'm not quite sure how you would use that.
    There is no greater sign that a computing technology is worthless than the association of the word "solution" with it.

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    The color of the polygon won't have effect on the color unless you change the texture environment mode to something like replace or modulate.

    as for glColor3ub I guess if you load a texture from a file which has the color information on it you could use that.

    And like you sed the normal is just the vector perpendicular to the surface of a polygon used to determine how light is reflected.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. lots of questions about opengl
    By n3v in forum Game Programming
    Replies: 9
    Last Post: 07-01-2006, 08:32 AM
  2. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 01:34 PM
  3. OpenGL Transparency Questions
    By Dante Shamest in forum Game Programming
    Replies: 7
    Last Post: 03-26-2005, 05:59 PM
  4. Some OpenGL Questions:
    By Krak in forum Game Programming
    Replies: 7
    Last Post: 04-29-2003, 01:07 AM
  5. MISC questions about OpenGL
    By Silvercord in forum Game Programming
    Replies: 12
    Last Post: 01-25-2003, 04:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21