Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Zzuumog

Pages: [1]
1
Graphics / Re: SFML -> OpenGL Texture Conversion Not Displaying
« on: May 31, 2012, 08:38:18 pm »
Thank you, sir, for your help. Switching to gluBuild2DMipmaps fixed the problem for me.

2
Graphics / SFML -> OpenGL Texture Conversion Not Displaying
« on: May 31, 2012, 05:08:35 am »
Problem:
Instead of displaying a texture, it displays a white quad.

Description of Problem:
I'm trying to display a simple texture onto a simple 2D square. Unfortunately, I seem to be having a great deal of difficulty and I'm not quite sure why. What I'm doing is using sf::Image and then taking the data and turning it into a OpenGL texture. The drawing goes perfectly and it displays a rectangle properly, however, my problem is that rather than displaying the texture I've specified, it displays white.

Code for loading the texture and converting it is here:
sf::Image Image;
if (!Image.loadFromFile(path)) {
    printf("An error occurred in loading the texture.");
}

glGenTextures(1, &FinalTexture);
glBindTexture(GL_TEXTURE_2D, FinalTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, Image.getSize().x, Image.getSize().y, 0, GL_RGB, GL_UNSIGNED_BYTE, Image.getPixelsPtr());
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
 

FinalTexture is defined as:
GLuint FinalTexture;
 

Method of binding & drawing
glBindTexture(GL_TEXTURE_2D, FinalTexture);
        glBegin(GL_QUADS);
            glTexCoord2f(0.f, 0.f); glVertex2f(0.f, 0.f);
            glTexCoord2f(1.f, 0.f); glVertex2f(32.f, 0.f);
            glTexCoord2f(1.f, 1.f); glVertex2f(32.f, 32.f);
            glTexCoord2f(0.f, 1.f); glVertex2f(0.f, 32.f);
        glEnd();
 

Image is loaded properly from what I've gathered using a Sprite

SFML Version: SFML 2.0 RC

Does anyone see anything wrong with what I'm doing? I've looked at quite a few example of OpenGL texture loading and this is what I've ascertained from them.

~Thanks

Pages: [1]