Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL - 2D Texture Mapping
    primarykey
    data
    text
    <p>I'm trying to render a simple texture(64x64) to a 64x64 quad. The quad itself is rendering, but, not the texture. (It's rendering a blank white 64x64 quad.)</p> <p>I'm using <a href="http://www.lonesock.net/soil.html" rel="nofollow noreferrer">SOIL</a> to load the image.</p> <pre><code>static GLuint LoadPNG(char* filename) { GLuint texture = SOIL_load_OGL_texture ( filename, SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT ); if (texture == 0) Log("Texture Load Error: " + string(filename)); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); return texture; } </code></pre> <p>This is my rendering code, I may not be mapping it correctly, so that could be the issue too.</p> <pre><code>// Draw Textured Quad static void glDrawTexturedQuad(glRectF rect, GLuint tex) { // Bind Texture glBindTexture (GL_TEXTURE_2D, tex); // Render Settings glEnable(GL_TEXTURE_2D); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); glColor3ub(255,255,255); glBegin(GL_QUADS); // Top Left glTexCoord2f(0, 1); glVertex2f(rect.X, rect.Y); // Top Right glTexCoord2f(1, 1); glVertex2f(rect.X + rect.Width, rect.Y); // Bottom Right glTexCoord2f(1, 0); glVertex2f(rect.X + rect.Width, rect.Y + rect.Height); // Bottom Left glTexCoord2f(0, 0); glVertex2f(rect.X, rect.Y + rect.Height); glEnd(); } </code></pre> <p>Here is the rest of the relevant code. (This is really just temp code, to glue it all together for testing, I'll come up with a better solution after I get it working.)</p> <pre><code>static GLuint Texture; static void LoadTextures() { Texture = LoadPNG("filename"); } static void glRenderTest() { glRectF rect = {20, 20, 64, 64}; glDrawTexturedQuad(rect, Texture); } </code></pre> <hr> <p>I've also followed all the suggestions found <a href="https://stackoverflow.com/questions/740151/what-are-the-usual-troubleshooting-steps-for-opengl-textures-not-showing">here</a> It's still not displaying my texture.</p> <hr> <p>I swapped out LodePNG for SOIL(Simple OpenGL Image Library), it's a bit easier to use, but still isn't working.</p> <p>I added glTexEnv as suggested in the answer below, but I'm still just getting a white box, I'll try some more settings, but I don't think that was it. (Edit: Tried various flags, nothing, still just a white quad.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload