void Graphics::drawImage( boost::shared_ptr<gcn::OpenGLImage> texture, Utilities::Rect& src, Utilities::Coord &dest, Utilities::Color& color )
{
assert( texture );
if( m_begansprites == false )
{
glEnable( GL_TEXTURE_2D );
glBegin( GL_QUADS );
m_begansprites = true;
}
// Draw the texture at it's default size if
// a size is not defined
if( src.width == 0 )
src.width = texture->getWidth();
if( src.height == 0 )
src.height = texture->getHeight();
float texX1 = src.x / (float)texture->getWidth();
float texY1 = src.y / (float)texture->getHeight();
float texX2 = (src.x + src.width) / (float)texture->getWidth();
float texY2 = (src.y + src.height) / (float)texture->getHeight();
glBindTexture( GL_TEXTURE_2D, texture->getTextureHandle() );
glColor4ub( color.r, color.g, color.b, color.a );
glTexCoord2f( texX1, texY1 );
glVertex2f( dest.x, dest.y );
glTexCoord2f( texX2, texY1 );
glVertex2f( dest.x + src.width, dest.y );
glTexCoord2f( texX2, texY2 );
glVertex2f( dest.x + src.width, dest.y + src.height );
glTexCoord2f( texX1, texY2 );
glVertex2f( dest.x, dest.y + src.height );
if( m_begansprites == true )
{
glEnd();
glDisable( GL_TEXTURE_2D );
m_begansprites = false;
}
}
Image not drawing
For some reason...my image isn't drawing. I know the image exists because I can write the values to the log(sizes return the right size, the texture handle returns the number 2), and the program isn't crashing when I try to draw the image. Its hard because the loading code is spread all over the place, but I doubt its the loading code.
theres certain things u cant do between glBegin()..End()
one of them is binding a texture like youre doing there
one of them is binding a texture like youre doing there
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement