#include "SDL.h" #include "SDL_opengl.h" #include #define WIDTH (768) #define HEIGHT WIDTH unsigned char pixels[WIDTH * HEIGHT * 4]; int main(void) { GLuint textureID; int i, j; SDL_Init(SDL_INIT_VIDEO); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); SDL_SetVideoMode(640, 480, 24, SDL_OPENGL); memset(pixels, 0xFF, sizeof(pixels)); glGenTextures(1, &textureID); glBindTexture(GL_TEXTURE_2D, textureID); glTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); // glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels); glGenerateMipmap(GL_TEXTURE_2D); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); // glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glClear(GL_COLOR_BUFFER_BIT); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textureID); glBegin(GL_QUADS); glTexCoord2f(0.f, 0.f); glVertex2f(-1.f, -1.f); glTexCoord2f(1.f, 0.f); glVertex2f(1.f, -1.f); glTexCoord2f(1.f, 1.f); glVertex2f(1.f, 1.f); glTexCoord2f(0.f, 1.f); glVertex2f(-1.f, 1.f); glEnd(); SDL_GL_SwapBuffers(); // Stay on the screen for a bit. SDL_Delay(1000); SDL_Quit(); return 0; }