Code: Alles auswählen
#include "SDL/SDL.h"
#include "SDL/SDL_opengl.h"
#include <iostream>
using namespace std;
int main(int, char**) {
GLfloat rtri = 0;
GLuint texture;
SDL_Surface* textureBMP;
SDL_Init(SDL_INIT_VIDEO);
SDL_Surface* screen = SDL_SetVideoMode(640, 480, 16, SDL_OPENGL);
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
textureBMP = SDL_LoadBMP("example.bmp");
glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureBMP->w, textureBMP->h, 0, GL_RGB, GL_UNSIGNED_BYTE, textureBMP->pixels);
glEnable(GL_TEXTURE_2D);
while(SDL_GetTicks() <= 5000) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
// render quad with texture
glBindTexture(GL_TEXTURE_2D, texture);
glBegin(GL_QUADS);
glTexCoord2f(0, 0); glVertex2f(0,0);
glTexCoord2f(1, 0); glVertex2f(1,0);
glTexCoord2f(1, 1); glVertex2f(1,1);
glTexCoord2f(0, 1); glVertex2f(0,1);
glEnd();
SDL_GL_SwapBuffers();
}
SDL_FreeSurface(textureBMP);
SDL_FreeSurface(screen);
}
LG Glocke