This is my code here:
#include <SDL/SDL.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glaux.h>
SDL_Surface *screen;
SDL_Event event;
GLuint texture;
SDL_Surface *img;
int main(int argc,char* argv[])
{
int start;
SDL_Init(SDL_INIT_EVERYTHING);
SDL_WM_SetCaption("OpenGL is the shiznit!",NULL);
screen = SDL_SetVideoMode(800,600,32, SDL_HWSURFACE | SDL_OPENGL);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER,1);
glEnable(GL_TEXTURE_2D);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, 800, 600, 0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
img = SDL_LoadBMP("lol.bmp");
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB,img->w,img->h,GL_RGB,GL_UNSIGNED_BYTE,img->pixels);
while(true)
{
start = SDL_GetTicks();
if(SDL_PollEvent(&event))
{
if(event.type == SDL_QUIT)
{
return false;
}
if(event.type == SDL_KEYDOWN)
{
if(event.key.keysym.sym == SDLK_ESCAPE)
{
return false;
}
}
}
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2i(0,0); glVertex2f(100.0f,100.0f);
glTexCoord2i(0,1); glVertex2f(100.0f + img->w,100.0f);
glTexCoord2i(1,1); glVertex2f(100.0f + img->w,100.0f + img->h);
glTexCoord2i(1,0); glVertex2f(100.0f,100.0f + img->h);
glEnd();
SDL_GL_SwapBuffers();
}
SDL_Quit();
return 0;
}
This is what i see after compiling and running:
And this is the original image:
I have no idea what im suppose to do :S