GRIM: Formatted code and added an assert that checks that object-pointers and function-pointers are of the same size before casting.
This commit is contained in:
parent
67487b8667
commit
22a5332a76
1 changed files with 8 additions and 7 deletions
|
@ -26,11 +26,6 @@
|
||||||
#undef ARRAYSIZE
|
#undef ARRAYSIZE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SDL_BACKEND
|
|
||||||
// We need SDL.h for SDL_GL_GetProcAddress.
|
|
||||||
#include "backends/platform/sdl/sdl-sys.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "common/endian.h"
|
#include "common/endian.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
|
|
||||||
|
@ -44,8 +39,13 @@
|
||||||
#include "engines/grim/bitmap.h"
|
#include "engines/grim/bitmap.h"
|
||||||
#include "engines/grim/primitives.h"
|
#include "engines/grim/primitives.h"
|
||||||
|
|
||||||
|
#ifdef USE_OPENGL
|
||||||
|
|
||||||
#if defined(SDL_BACKEND)
|
#if defined(SDL_BACKEND)
|
||||||
|
|
||||||
|
// We need SDL.h for SDL_GL_GetProcAddress.
|
||||||
|
#include "backends/platform/sdl/sdl-sys.h"
|
||||||
|
|
||||||
// Extension functions needed for fragment programs.
|
// Extension functions needed for fragment programs.
|
||||||
PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
|
PFNGLGENPROGRAMSARBPROC glGenProgramsARB;
|
||||||
PFNGLBINDPROGRAMARBPROC glBindProgramARB;
|
PFNGLBINDPROGRAMARBPROC glBindProgramARB;
|
||||||
|
@ -54,8 +54,6 @@ PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
|
||||||
|
|
||||||
namespace Grim {
|
namespace Grim {
|
||||||
|
|
||||||
// Simple ARB fragment program that writes the value from a texture to the Z-buffer.
|
// Simple ARB fragment program that writes the value from a texture to the Z-buffer.
|
||||||
|
@ -119,6 +117,9 @@ void GfxOpenGL::initExtensions()
|
||||||
void* obj_ptr;
|
void* obj_ptr;
|
||||||
void (APIENTRY *func_ptr)();
|
void (APIENTRY *func_ptr)();
|
||||||
} u;
|
} u;
|
||||||
|
// We're casting from an object pointer to a function pointer, the
|
||||||
|
// sizes need to be the same for this to work.
|
||||||
|
assert(sizeof(u.obj_ptr) == sizeof(u.func_ptr));
|
||||||
u.obj_ptr = SDL_GL_GetProcAddress("glGenProgramsARB");
|
u.obj_ptr = SDL_GL_GetProcAddress("glGenProgramsARB");
|
||||||
glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)u.func_ptr;
|
glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC)u.func_ptr;
|
||||||
u.obj_ptr = SDL_GL_GetProcAddress("glBindProgramARB");
|
u.obj_ptr = SDL_GL_GetProcAddress("glBindProgramARB");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue