summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tiletex.cc
diff options
context:
space:
mode:
authorIxtli <cg@325i.org>2010-03-03 00:36:07 +0900
committerEnne Walker <ennewalker@users.sourceforge.net>2010-04-24 10:19:40 -0400
commitef69303d12fe064332616c431f33fc69a3c740a9 (patch)
tree5ff3f56d7d377cb714410a5f3db4465e636c3813 /crawl-ref/source/tiletex.cc
parent5c4d00b30329fcff7b3f600af81af0e9a59ac3fa (diff)
downloadcrawl-ref-ef69303d12fe064332616c431f33fc69a3c740a9.tar.gz
crawl-ref-ef69303d12fe064332616c431f33fc69a3c740a9.zip
Removed tiletex dependancy on SDL_opengl and updated glwrapper.h/cc to support it
Diffstat (limited to 'crawl-ref/source/tiletex.cc')
-rw-r--r--crawl-ref/source/tiletex.cc46
1 files changed, 10 insertions, 36 deletions
diff --git a/crawl-ref/source/tiletex.cc b/crawl-ref/source/tiletex.cc
index 04574c36b3..e1886e6cbc 100644
--- a/crawl-ref/source/tiletex.cc
+++ b/crawl-ref/source/tiletex.cc
@@ -10,7 +10,9 @@
#include "cgcontext-sdl.h"
#endif
-#include <SDL_opengl.h>
+#ifdef USE_GL
+#include "glwrapper.h"
+#endif
GenericTexture::GenericTexture() :
m_handle(0),
@@ -31,7 +33,7 @@ void GenericTexture::unload_texture()
if (!m_handle)
return;
- glDeleteTextures(1, (GLuint*)&m_handle);
+ GLStateManager::deleteTextures(1, &m_handle);
}
bool GenericTexture::load_texture(const char *filename,
@@ -64,7 +66,7 @@ bool GenericTexture::load_texture(const char *filename,
}
unsigned int bpp = img->bytesPerPixel();
- glPixelStorei(GL_UNPACK_ALIGNMENT, bpp);
+ GLStateManager::pixelStoreUnpackAlignment(bpp);
// Determine texture format
unsigned char *pixels = (unsigned char*)img->pixels();
@@ -87,7 +89,6 @@ bool GenericTexture::load_texture(const char *filename,
new_height = img->height();
}
- GLenum texture_format;
if (bpp == 4)
{
// Even if the size is the same, still go through
@@ -112,7 +113,6 @@ bool GenericTexture::load_texture(const char *filename,
}
img->unlock();
- texture_format = GL_RGBA;
}
else if (bpp == 3)
{
@@ -143,7 +143,6 @@ bool GenericTexture::load_texture(const char *filename,
img->unlock();
}
- texture_format = GL_RGBA;
}
else if (bpp == 1)
{
@@ -193,7 +192,6 @@ bool GenericTexture::load_texture(const char *filename,
img->unlock();
bpp = 4;
- texture_format = GL_RGBA;
}
else
{
@@ -225,36 +223,12 @@ bool GenericTexture::load_texture(unsigned char *pixels, unsigned int new_width,
if (!pixels || !new_width || !new_height)
return (false);
- // Assumptions...
- const unsigned int bpp = 4;
- const GLenum texture_format = GL_RGBA;
- const GLenum format = GL_UNSIGNED_BYTE;
-
m_width = new_width;
m_height = new_height;
- glGenTextures(1, (GLuint*)&m_handle);
- glBindTexture(GL_TEXTURE_2D, m_handle);
-
- glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
-
- if (mip_opt == MIPMAP_CREATE)
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- gluBuild2DMipmaps(GL_TEXTURE_2D, bpp, m_width, m_height,
- texture_format, format, pixels);
- }
- else
- {
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, bpp, m_width, m_height, 0,
- texture_format, format, pixels);
- }
+ GLStateManager::generateTextures(1, &m_handle);
+ GLStateManager::bindTexture(m_handle);
+ GLStateManager::loadTexture(pixels, m_width, m_height, mip_opt);
return (true);
}
@@ -262,13 +236,13 @@ bool GenericTexture::load_texture(unsigned char *pixels, unsigned int new_width,
void GenericTexture::bind() const
{
ASSERT(m_handle);
- glBindTexture(GL_TEXTURE_2D, m_handle);
+ GLStateManager::bindTexture(m_handle);
}
TilesTexture::TilesTexture() :
GenericTexture(), m_tile_max(0), m_info_func(NULL)
{
-
+
}
void TilesTexture::set_info(int tile_max, tile_info_func *info_func)