Jump to content
  • Advertisement
Sign in to follow this  
Genjix

OpenGL wxImage::GetAlpha and OpenGL

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

Hello, As I understand it wxImage::GetData() returns *uchar[3] (RGB) and wxImage::GetAlpha() returns *uchar[1](A). I am using a wxGLCanvas and to load textures I have this function
def LoadTexture(tex_src , tex_id , size):
	tex_id[0] = glGenTextures(1)
	glBindTexture(GL_TEXTURE_2D, tex_id[0])

	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)

	wximage = wxImage(tex_src)

	size.append(wximage.GetWidth())
	size.append(wximage.GetHeight())

	# i think OpenGL does this for us...
	# either way OpenGL resize is faster & easier
	#if not isCompliant(glImage))
	#	glImage = makeGLCompliant(glImage);

	# how to get the alpha channel together with pixel data
	if wximage.HasAlpha():
		glTexImage2D(GL_TEXTURE_2D , 0 , GL_RGB , wximage.GetWidth(),
				wximage.GetHeight() , 0 , GL_RGB , GL_UNSIGNED_BYTE , wximage.GetData())
	else:
		glTexImage2D(GL_TEXTURE_2D , 0 , GL_RGB , wximage.GetWidth(),
				wximage.GetHeight() , 0 , GL_RGB , GL_UNSIGNED_BYTE , wximage.GetData())

	return tex_id

Any clues on how I can load the image alpha into OpenGL (GL_RGBA) without cocantenating a new pixel array O_O?

Share this post


Link to post
Share on other sites
Advertisement
There is no decent way to do that. The way wxImage stores Alpha in a seperate buffer makes this a problem. You need to make a new buffer and interleave the RGB and the A into the one buffer, and give that to glTexImage2D().

Or use something else to load the images, like DevIL.

Share this post


Link to post
Share on other sites
ok, thank you very much.

I already have an SDL loader, but wanted to reduce the SDL dependency.
This is just what I thought :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!