I’m writing this assuming you’re using the code I sent you.
The reason is that OpenGL only supports textures of size power of
two. The nearest power of two to 100 is 128, so you’ll have a 28
pixel border if you don’t compensate for this. The way to get around
it is to adjust the texture coordinates of the quad.
GLfloat maxu = (GLfloat) texture_converted->w / pot(texture_converted-
GLfloat maxv = (GLfloat) texture_converted->h / pot(texture_converted-
glTexCoord2f( 0, 0);
glVertex2i( 0, 0 );
glTexCoord2f( maxu, 0);
glVertex2i( texture_converted->w, 0 );
glTexCoord2f( maxu, maxv);
glVertex2i( texture_converted->w, texture_converted->h );
glTexCoord2f( 0, maxv);
glVertex2i( 0, texture_converted->h );
What this does is it uses fractional texture coordinates depending on
the ratio of the used image size to the total size of the image. The
code should roughly work, but may have an error here or there and may
make your image upside down. Code mostly there to show you what to do
- HolmesOn Aug 23, 2008, at 10:09 AM, Abhinav Lele wrote:
I am rendering a texture from a 100x100 image (jpg) after loading it
using SDL_Image. But I get an unwanted black patch surrounding the
texture. Does someone know the possible reason ?
Here is the screenshot of the window
The first box is a 50x50 box. The actual size of the image is 100x100.
Image is loaded using the following code from sdl_surface
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB,
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture_converted->w,
texture_converted->h, GL_RGB, GL_UNSIGNED_BYTE, texture_converted-
SDL mailing list
SDL at lists.libsdl.org