Advertisement

Textures aren't loaded

Started by February 28, 2003 06:27 AM
8 comments, last by Lyve 21 years, 11 months ago
Hello list, I''m still working on the problem that textures aren''t loaded sometimes, why ever. I''ve noticed something strange: I kill a texture with glDeleteTextures() that was loaded properly. Now I call glGenTextures() to create a new texture (and I receive the same GLuint as the texture that I''ve deleted before). If I specify a new texturemap with glTexImage2D() now, the texture image isn''t replaced?! Any ideas? Nils _____________________________________ Visit http://www.nilsschneider.de for finest trance music, studio, bio, guestbook and more!
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
Ufff...
Source code?

PM



Times change.


Excuse my poor english!
PM Times change... Excuse my poor english!
Advertisement
Are you rebinding the new texture?
make sure your texture sizes are in powers of two (that is, if you''re not building mip-maps)
quote:

(that is, if you''re not building mip-maps)


Mipmaps also have to be a power of two.
quote:
Original post by Brother Bob
Mipmaps also have to be a power of two.

That''s right, but if u use gluBuild2DMipmaps, it will scale your image to the next higher power of two...





PM



Times change.


Excuse my poor english!
PM Times change... Excuse my poor english!
Advertisement
Lyve, the behavior is correct, if you glDeleteTexture() a texture, then that texture ID is free to be used again, and will be for your next texture.

My theory is you are not clearing your variables.

If that doesn''t work, post source, because this is a complicated problem, one I''ve never delt with...
~~~~~Screaming Statue Software. | OpenGL FontLibWhy does Data talk to the computer? Surely he's Wi-Fi enabled... - phaseburn
Ok, here is the source code. I've checked power of two, and I've also checked rebinding, everything is ok. Any wrong things in this code?

Lyve
------------------------

      CTexture::CTexture(){	// ....load texture.....	ASSERT( m_nWidth );	ASSERT( m_nHeight );	ASSERT( !(m_nWidth & (m_nWidth-1)) );	ASSERT( !(m_nHeight & (m_nHeight-1)) );	ASSERT( m_pRgbaData );	GLVERIFY( glGenTextures( 1, &m_textureIdx ) );	GLVERIFY( glBindTexture( GL_TEXTURE_2D, m_textureIdx) );	GLVERIFY( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) );	GLVERIFY( glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) );	GLVERIFY( glTexImage2D(GL_TEXTURE_2D, 0, 4, m_nWidth, m_nHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_pRgbaData) );	GLVERIFY( gluBuild2DMipmaps(GL_TEXTURE_2D, 4, m_nWidth, m_nHeight, GL_RGBA, GL_UNSIGNED_BYTE, m_pRgbaData) );}CTexture::~CTexture(){	GLVERIFY( glDeleteTextures( 1, &m_textureIdx ) );	delete[] m_pRgbaData;}      


_____________________________________
Visit < href="http://www.nilsschneider.de">http://www.nilsschneider.de for finest trance music, studio, bio, guestbook and more!

[edited by - Lyve on March 6, 2003 11:15:18 AM]

[edited by - Lyve on March 6, 2003 11:16:40 AM]
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
1. Why your are calling gluBuild2DMipmaps after glTexture2D???
2. Are u sure m_pRgbaData was reloaded? ()

PM



I hope GeForce FX is a joke .


Excuse my poor english!
PM Times change... Excuse my poor english!
Hm, you''re right. I''ve removed the other call. And yes, the texture data is destroyed, look into the destructor

Lyve
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.

This topic is closed to new replies.

Advertisement