- // 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);
- w = 512;
- h = 512;
-
- switch ( texturebpp )
- {
- case 16:
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
-
-// rmask = 0xff000000;
-// gmask = 0x00ff0000;
-// bmask = 0x0000ff00;
-// amask = 0x00000000;
-
- rmask = 0x0000;
- gmask = 0x0000;
- bmask = 0x0000;
- amask = 0x0000;
-
- #else
-
-// rmask = 0x000000ff;
-// gmask = 0x0000ff00;
-// bmask = 0x00ff0000;
-// amask = 0x00000000;
-
- rmask = 0x0000;
- gmask = 0x0000;
- bmask = 0x0000;
- amask = 0x0000;
-
- #endif
-
- break;
- case 24:
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0x00ff0000;
- gmask = 0x0000ff00;
- bmask = 0x000000ff;
- amask = 0x00000000;
- #else
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0x00000000;
- #endif
- break;
- case 32:
- default:
- #if SDL_BYTEORDER == SDL_BIG_ENDIAN
- rmask = 0xff000000;
- gmask = 0x00ff0000;
- bmask = 0x0000ff00;
- amask = 0x000000ff;
- #else
- rmask = 0x000000ff;
- gmask = 0x0000ff00;
- bmask = 0x00ff0000;
- amask = 0xff000000;
- #endif
- break;
- }
-
- // create texture surface
- texture = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask);
-/*
- #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);
-
- glDisable(GL_FOG);
- glDisable(GL_LIGHTING);
- glDisable(GL_CULL_FACE);
- glDisable(GL_DEPTH_TEST);
- glDisable(GL_BLEND);
- glDisable(GL_NORMALIZE);
- glDisable(GL_ALPHA_TEST);
- glEnable(GL_TEXTURE_2D);
- glBlendFunc (GL_SRC_ALPHA, GL_ONE);
-
- 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);
- }
-
- switch ( texturebpp )
- {
- case 16:
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
- break;
- case 24:
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
- break;
- case 32:
- default:
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture->w, texture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
- break;
- }