I want to simply insert an image in opengl using SOIL

99 Views Asked by At

This is the code I'm using, but its not loading anything: It is supposed to load frog.png onto a window. The image is present is the cwd. The output im getting is a blank screen with nothing on it. Am I missing some functions ?

#include <math.h>
#include <GL/glut.h>
#include<stdio.h>
#include<SOIL.h>

void init(void){

        glClearColor(1.0,1.0,1.0,1.0); 
        glMatrixMode(GL_PROJECTION);
        gluOrtho2D(0.0,300.0,0.0,300.0);
    }


void drawPoints(void){

        glClear(GL_COLOR_BUFFER_BIT);
        glColor3f(1,0.4,0.6);//rgb values

       GLuint tex_2d = SOIL_load_OGL_texture
    (
        "frog.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() );
}
        glFlush();
}

int main(int argc, char **argv){

        glutInit(&argc,argv);
        glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
        glutInitWindowPosition(100,100); 
        glutInitWindowSize(100,100); 
        glutCreateWindow("example");
        init();
        glutDisplayFunc(drawPoints);
        glutMainLoop(); 
}
0

There are 0 best solutions below