Sign in to follow this  
AnarchicBunny

[SOLVED ] Troubles with Cube Maps

Recommended Posts

I've been having a bit of trouble getting cube maps to work properly. The code here has been pared back to a very simple test of correctness: the cube map is all red, so the sphere should be also. Unfortunately, it stays white (or green, or blue, if I change the glColor3f call). I assume I'm overlooking something very simple, but I have no idea what it is. Any help would be welcome.
GLuint texture;

void init_render()
{
	glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_CUBE_MAP_EXT, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); 
	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); 
	glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_EXT); 
	glEnable(GL_TEXTURE_GEN_S); 
	glEnable(GL_TEXTURE_GEN_T); 
	glEnable(GL_TEXTURE_GEN_R);

	glEnable(GL_TEXTURE_CUBE_MAP_EXT);

	GLubyte blank[256][256][3];
	
	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_CUBE_MAP_EXT, texture);
	
	
	for (int i = 0; i < 256; i++)
		for (int j = 0; j < 256; j++)
		{
			blank[i][j][0] = (GLubyte) 255;
			blank[i][j][1] = (GLubyte) 0;
			blank[i][j][2] = (GLubyte) 0;
		}
			
		
		
	for (int i = 0; i < 6; i++)
		glTexImage2D(face[i], 0, GL_RGB, 256, 256, 0, GL_RGB, GL_UNSIGNED_BYTE, blank);

	

}

void render(Camera camera)
{
	glColor3f(1,1,1);
	
	
	camera.translate();
	
	GLUquadricObj* quadric = gluNewQuadric();
	gluQuadricOrientation(quadric, GLU_OUTSIDE);
	gluSphere(quadric, 1, 50, 50);
}




[Edited by - AnarchicBunny on July 20, 2005 9:02:54 PM]

Share this post


Link to post
Share on other sites
its white cause the texture didnt get setup correctly, try glgeterror().
also check the gl spec (the part about texture correctness) -- heres a bit
3.8.10 Texture Completeness
A texture is said to be complete if all the image arrays and texture parameters
required to utilize the texture for texture application is consistently defined. The
definition of completeness varies depending on the texture dimensionality.
For one-, two-,

(read the rest)

Share this post


Link to post
Share on other sites
It says the requirements are:
•The levelbase arrays of each of the six texture images making up the cube
map have identical, positive, and square dimensions.
• The levelbase arrays were each specified with the same internal format.
• The levelbase arrays each have the same border width.

Now, correct me if I'm wrong, but aren't all of these satisfied by the above code? And as I said, it's not just white, it's any color I set it to. I know that a white texture generally points to some error in how I set the textures up, but that doesn't seem to be the case here.

Share this post


Link to post
Share on other sites
Wrapping doesn't change anything, and glGetError returns 0 every frame.

glIntercept, on the other hand, demonstrated something odd. I noticed the nVidia demos don't generate or bind any textures, and yet somehow work. Even odder still, when I take out either the glGenTexture or glBindTexture calls, my cube maps work. When both of them are called, though, it's back to the blank sphere.

I have to admit, I'm more confused than ever.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this