SOIL, putting texture on rectangle

Started by
1 comment, last by swiftcoder 15 years, 2 months ago
Hi, I want to insert an image on a rectangular quad using SOIL. It's my first time using SOIL and I have no clue how to use it. That's my code. //---------------------------------------------------------------------- GLuint tex_2d = SOIL_load_OGL_texture ( "img.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT ); /* check for an error during the load process */ if( 0 == tex_2d ) { printf( "SOIL loading error: '%s'\n", SOIL_last_result() ); } glBegin(GL_POLYGON); glVertex2f(50,50); glVertex2f(50,200); glVertex2f(200,200); glVertex2f(200,50); glEnd(); //----------------------------------------------------------------------- It loads an image into an array. Then I draw a rectangle using GL_QUADS. But how do i put the image on the quad? Thanks.
Advertisement
sorry I mean I use glBegin(GL_POLYGON);
Your quad/polygon needs texture coordinates. Check the documentation for glTexCoord2f.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

This topic is closed to new replies.

Advertisement