• Advertisement

Archived

This topic is now archived and is closed to further replies.

multiple glCopyTex(Sub)Image2D fails

This topic is 5066 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I want to create a cubemap out of dynamically renderd camera-perspectives. I want to do this by simply turning the camera, take a picture (for texture use later), turn again, take picture, and so on. But for this, i need 6 glCopyTexImage2D or glCopyTexSubImage2D-calls. But i only get the last Call of this function to really generate a texture! I have 6 absolutely different texture-Identifiers generated via glGenTexture that have different values. But whatever i do, i get the SAME texture for all of these six whenever Copying! Where is the clue? Initialisation:
 
        glGenTextures(1, &m_Env_Textures_0);
	glGenTextures(1, &m_Env_Textures_1);
	glGenTextures(1, &m_Env_Textures_2);
	glGenTextures(1, &m_Env_Textures_3);
	glGenTextures(1, &m_Env_Textures_4);
	glGenTextures(1, &m_Env_Textures_5);
// 	for (int i=0; i<6; i++){


		glBindTexture(GL_TEXTURE_2D, m_Env_Textures_0);
	
		glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_INT, pTexture);                        
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

		glBindTexture(GL_TEXTURE_2D, m_Env_Textures_1);
		glTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 512, 0, GL_RGB, GL_UNSIGNED_INT, pTexture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
...
Creating Textures (its the same effect using glCopyTexSubImage2D or glCopyTexImage2D):
        glViewport(0, 0, 512, 512);
	
	//FRONT

	g_camera.m_fYaw=0; g_camera.m_fPitch=0;
	Render( );
	glBindTexture(GL_TEXTURE_2D, m_Env_Textures_0);
        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);
 	//LEFT

	g_camera.m_fYaw=0; g_camera.m_fPitch-=90;
	Render( );
	glBindTexture(GL_TEXTURE_2D,m_Env_Textures_1);
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);
	//BEHIND

	g_camera.m_fYaw=0; g_camera.m_fPitch-=90;
	Render( );
	glBindTexture(GL_TEXTURE_2D,m_Env_Textures_2);
	glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 512, 512);
...
Rendering using these textures:
glBindTexture(GL_TEXTURE_2D, m_Env_Textures_0);
	glTexCoord2f(0.0f, 0.0f );	glVertex3fv(v0);
        glTexCoord2f(0.0f, 1.0f );	glVertex3fv(v1);
        glTexCoord2f(1.0f, 1.0f );	glVertex3fv(v2); 
        glTexCoord2f(1.0f, 0.0f );	glVertex3fv(v3);
    
//         // Assign the texture coordinates and vertices for the FRONT Side

	glBindTexture(GL_TEXTURE_2D, m_Env_Textures_1);
	glTexCoord2f(0.0f, 0.0f );	glVertex3fv(v4);
        glTexCoord2f(0.0f, 1.0f );	glVertex3fv(v5);
        glTexCoord2f(1.0f, 1.0f );	glVertex3fv(v6); 
        glTexCoord2f(1.0f, 0.0f );	glVertex3fv(v7);
//     

//         // Assign the texture coordinates and vertices for the BOTTOM Side

	glBindTexture(GL_TEXTURE_2D, m_Env_Textures_2);
	glTexCoord2f(0.0f, 0.0f );	glVertex3fv(v0);
        glTexCoord2f(0.0f, 1.0f );	glVertex3fv(v4);
        glTexCoord2f(1.0f, 1.0f );	glVertex3fv(v7); 
        glTexCoord2f(1.0f, 0.0f );	glVertex3fv(v3);
I''d helpful for any help.

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement