texture_width = next_power_of_two(image->w);
texture_height = next_power_of_two(image->h);
#else
- texture_width = image->w;
- texture_height = image->h;
+ if (GLEW_ARB_texture_non_power_of_two)
+ {
+ texture_width = image->w;
+ texture_height = image->h;
+ }
+ else
+ {
+ texture_width = next_power_of_two(image->w);
+ texture_height = next_power_of_two(image->h);
+ }
#endif
image_width = image->w;
throw std::runtime_error("Couldn't create texture: out of memory");
}
- SDL_SetAlpha(image, 0, 0);
+ //SDL_SetAlpha(image, 0, 0);
SDL_BlitSurface(image, 0, convert, 0);
assert_gl("before creating texture");
sdl_format = GL_RGB;
else if(convert->format->BytesPerPixel == 4)
sdl_format = GL_RGBA;
- else
+ else {
+ sdl_format = GL_RGBA;
assert(false);
+ }
glBindTexture(GL_TEXTURE_2D, handle);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
{
SDL_LockSurface(convert);
}
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
+
+ if (true)
+ { // no not use mipmaps
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
texture_height, 0, sdl_format,
GL_UNSIGNED_BYTE, convert->pixels);
+ }
+ else
+ { // build mipmaps
+ gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGBA, texture_width,
+ texture_height, sdl_format,
+ GL_UNSIGNED_BYTE, convert->pixels);
+ }
+
if(SDL_MUSTLOCK(convert))
{
SDL_UnlockSurface(convert);
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-#ifdef GL_CLAMP
- /* OpenGL ES doesn't support it */
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-#endif
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
assert_gl("set texture params");
}