[Add] Check for multitexture abilities and texture leaks.
This commit is contained in:
parent
5584c3171c
commit
475aa1f1fa
22
src/opengl.c
22
src/opengl.c
@ -14,6 +14,9 @@
|
||||
#include "pack.h"
|
||||
#include "opengl.h"
|
||||
|
||||
/* Requirements. */
|
||||
#define OPENGL_REQ_MULTITEX 3
|
||||
|
||||
/* The screen info, gives data of current opengl settings. */
|
||||
glInfo gl_screen;
|
||||
|
||||
@ -896,8 +899,9 @@ int gl_init(void) {
|
||||
if(gl_hasExt("GL_ARB_fragment_shader")==GL_TRUE)
|
||||
gl_screen.flags |= OPENGL_FRAG_SHADER;
|
||||
|
||||
/* Max texture size. */
|
||||
/* Texture information. */
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &gl_screen.tex_max);
|
||||
glGetIntegerv(GL_MAX_TEXTURE_UNITS, &gl_screen.multitex_max);
|
||||
|
||||
/* Debug heaven. */
|
||||
DEBUG("OpenGL Window Created: %dx%d@%dbpp %s", SCREEN_W, SCREEN_H,
|
||||
@ -910,8 +914,12 @@ int gl_init(void) {
|
||||
|
||||
DEBUG("Renderer: %s", glGetString(GL_RENDERER));
|
||||
DEBUG("Version: %s", glGetString(GL_VERSION));
|
||||
/* Now check for things that can be bad. */
|
||||
if(gl_screen.multitex_max < OPENGL_REQ_MULTITEX)
|
||||
WARN("Missing texture units (%d required, %d found)",
|
||||
OPENGL_REQ_MULTITEX, gl_screen.multitex_max);
|
||||
if(!gl_has(OPENGL_FRAG_SHADER))
|
||||
DEBUG("No fragment shader extension detected");
|
||||
DEBUG("No fragment shader extension detected"); /* Not a warning yet. */
|
||||
DEBUG("");
|
||||
|
||||
/* Some openGL options. */
|
||||
@ -947,6 +955,16 @@ int gl_init(void) {
|
||||
|
||||
/* Clean up our mess. */
|
||||
void gl_exit(void) {
|
||||
glTexList* tex;
|
||||
|
||||
/* Make sure there's no texture leak. */
|
||||
if(texture_list != NULL) {
|
||||
DEBUG("Texture leak detected!");
|
||||
for(tex = texture_list; tex != NULL; tex = tex->next)
|
||||
DEBUG(" '%s' opened %d times", tex->tex->name, tex->used);
|
||||
}
|
||||
|
||||
/* Shut down the subsystem. */
|
||||
SDL_QuitSubSystem(SDL_INIT_VIDEO);
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ typedef struct glInfo_ {
|
||||
int r, g, b, a; /* Framebuffer values in bits. */
|
||||
int flags; /* Store different properties. */
|
||||
int tex_max; /* Max texture size. */
|
||||
int multitex_max; /* Max multitexture levels. */
|
||||
} glInfo;
|
||||
extern glInfo gl_screen; /* Local structure set with gl_init etc. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user