Jump to content
  • Advertisement

Archived

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

POINT

glTexSubImage2D problems

This topic is 6481 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

the following code is used to draw a black transparent square hole into a 2d (to simulate bits of level getting blown up!). the problem is: the level remains unchanged
  
//vars: l, r, t, b (left, right, top, bottom) are long''s and are definately within the bounds of the texture


unsigned char* pixel = NULL;

	for(int x=l; x<r; ++x)
	{
		for(int y=t; y<b; ++y)
		{
			pixel = &m_image->Bytes[(y*m_image->Width*m_image->BytesPerPixel) + (x*m_image->BytesPerPixel)];

			*(pixel+0) = 0;
			*(pixel+1) = 0;
			*(pixel+2) = 0;
			*(pixel+3) = 0;
		}
	}

	glBindTexture(GL_TEXTURE_2D, m_maintexture);	
	glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_image->Width, m_image->Height, GL_RGBA, GL_UNSIGNED_BYTE, m_image->Bytes);
	//gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, m_image->Width, m_image->Height, GL_BGRA_EXT, GL_UNSIGNED_BYTE, m_image->Bytes);

  
if i use the commented gluBuild2DMipMaps line instead of texsubimage, it works (but is slooooow) which verifies the validity of m_image. im not concerned with any optimisations for now - just getting it working at a decent speed (ie not using build2dmips func).

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
You do not have width and height the power of two in glTexSubImage2D so that does not verify the validity of m_image.

Share this post


Link to post
Share on other sites
no need to be powers of 2
ill say you''re doing someit wrong with the pointers
are both textures RGBA ones?

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!