- // Texture width/height should be power of 2
- // So, find the largest power of two that will contain both the width and height
- w = power_of_two(src->w);
- h = power_of_two(src->h);
-
- // create texture surface
- texture = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 32,
- #if SDL_BYTEORDER == SDL_LIL_ENDIAN
- 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000);
- #else
- 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
- #endif
-
- // setup 2D gl environment
- glPushAttrib(GL_ENABLE_BIT);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_CULL_FACE);
- glEnable(GL_TEXTURE_2D);
-
- glViewport(0, 0, src->w * size, src->h * size);
-
- glMatrixMode(GL_PROJECTION);
- glPushMatrix();
- glLoadIdentity();
-
- glOrtho(0.0, (GLdouble)(src->w * size), (GLdouble)(src->h * size), 0.0, 0.0, 1.0);
- glMatrixMode(GL_MODELVIEW);
- glPushMatrix();
- glLoadIdentity();
-
- // texture coordinates
- texcoord[0] = 0.0f;
- texcoord[1] = 0.0f;
- texcoord[2] = (GLfloat)(src->w) / texture->w;
- texcoord[3] = (GLfloat)(src->h) / texture->h;
-
- // create an RGBA texture for the texture surface
- glGenTextures(1, &texid);
- glBindTexture(GL_TEXTURE_2D, texid);
-
- if (glFilter)
- {
- printf("OpenGL filters: enabled\n");
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- }
- else
- {
- printf("OpenGL filters: disabled\n");
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- }