Skip to content

Commit

Permalink
Refactored interface to OpenGL with a minimum requirement of version 1.4
Browse files Browse the repository at this point in the history
* If the implementation reports a lower than required version; display a critical message and gracefully abort startup.
* Reworked GL_state with a more practical distinction between high-level "features" (abstract) and the implementation/vendor specific extensions used to implement them. Availability of features considered static post initialization.
* Multitexture functionaliy assumed present.
* Cleaned up GL initialization centralising all default state configuration in Sys_GLConfigureDefaultState.
* Pruned dead code for unused extensions.

Todo: I've left the texture combiner stuff alone for now as I've no way to test any potential changes on anything other than my main dev system presently (which effectively means the NVIDIA paths only).
  • Loading branch information
danij-deng committed Mar 7, 2011
1 parent 704510a commit 1b14462
Show file tree
Hide file tree
Showing 16 changed files with 307 additions and 363 deletions.
7 changes: 0 additions & 7 deletions doomsday/engine/portable/include/gl_main.h
Expand Up @@ -81,13 +81,6 @@ const char* GL_ChooseFixedFont(void);
const char* GL_ChooseVariableFont(glfontstyle_t style, int resX, int resY);
void GL_LowRes(void);

/**
* Set the currently active GL texture unit by ident.
*
* @param texture GL texture unit ident to make active.
*/
void GL_ActiveTexture(const DGLenum texture);

void GL_ModulateTexture(int mode);
void GL_SelectTexUnits(int count);
void GL_SetTextureCompression(boolean on);
Expand Down
69 changes: 30 additions & 39 deletions doomsday/engine/portable/include/sys_opengl.h
Expand Up @@ -60,49 +60,52 @@
* Configure available features
* \todo Move out of this header.
*/
#define USE_MULTITEXTURE 1
#define USE_TEXTURE_COMPRESSION_S3 1

/**
* High-level GL state information.
*/
typedef struct gl_state_s {
/// Global config:
boolean forceFinishBeforeSwap;
int maxTexFilterAniso;
int maxTexSize;
#ifdef USE_MULTITEXTURE
int maxTexSize; // Logical pixels.
int maxTexUnits;
#endif
#if WIN32
int multisampleFormat;
#endif
boolean allowTexCompression;
boolean forceFinishBeforeSwap;
boolean haveCubeMap;
boolean useArrays;
boolean useFog;
boolean useMultiTex;
boolean useTexCompression;
boolean useTexFilterAniso;
boolean useVSync;
float currentLineWidth, currentPointSize;

/// Current state:
boolean currentUseFog;
boolean currentUseTexCompression;
float currentGrayMipmapFactor;
// Extension availability bits:
float currentLineWidth;
float currentPointSize;

/// Feature (abstract) availability bits:
/// Vendor and implementation agnostic.
struct {
uint blendSubtract : 1;
uint elementArrays : 1;
uint genMipmap : 1;
uint multisample : 1;
uint texCompression : 1;
uint texFilterAniso : 1;
uint texNonPowTwo : 1;
uint vsync : 1;
} features;

/// Extension availability bits:
struct {
uint blendSub : 1;
uint framebufferObject : 1;
uint genMipmapSGIS : 1;
uint lockArray : 1;
#ifdef USE_MULTITEXTURE
uint multiTex : 1;
#endif
#ifdef USE_TEXTURE_COMPRESSION_S3
uint texCompressionS3 : 1;
#endif
uint texEnvComb : 1;
uint texEnvCombNV : 1;
uint texEnvCombATI : 1;
uint texFilterAniso : 1;
uint texNonPow2 : 1;
uint texNonPowTwo : 1;
#if WIN32
uint wglMultisampleARB : 1;
uint wglSwapIntervalEXT : 1;
Expand All @@ -123,31 +126,19 @@ typedef enum arraytype_e {
AR_TEXCOORD7
} arraytype_t;

#ifdef USE_MULTITEXTURE
# define DGL_MAX_TEXTURE_UNITS (GL_state.useMultiTex? GL_state.maxTexUnits : 1)
# ifdef WIN32
extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTextureARB;
extern PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB;
extern PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fvARB;
# endif
#else
# define DGL_MAX_TEXTURE_UNITS (1)
#endif

extern gl_state_t GL_state;

#ifdef WIN32
# ifdef GL_EXT_framebuffer_object
extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
# endif

extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;

extern PFNGLBLENDEQUATIONEXTPROC glBlendEquationEXT;
extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
extern PFNGLCLIENTACTIVETEXTUREARBPROC glClientActiveTexture;
extern PFNGLACTIVETEXTUREARBPROC glActiveTexture;
extern PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f;
extern PFNGLMULTITEXCOORD2FVARBPROC glMultiTexCoord2fv;
#endif

#ifndef GL_ATI_texture_env_combine3
Expand Down Expand Up @@ -186,4 +177,4 @@ boolean Sys_GLQueryExtension(const char* name, const GLubyte* extensions);

boolean Sys_GLCheckError(void);

#endif /* LIBDENG_SYSTEM_OPENGL_H */
#endif /* LIBDENG_SYSTEM_OPENGL_H */
12 changes: 7 additions & 5 deletions doomsday/engine/portable/include/sys_system.h
@@ -1,10 +1,10 @@
/**\file
/**\file sys_system.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2010 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2010 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2011 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2006 Jamie Jones <jamie_jones_au@yahoo.com.au>
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -24,7 +24,7 @@
*/

/**
* sys_system.h: OS Specific Services Subsystem
* OS Specific Services Subsystem.
*/

#ifndef LIBDENG_FILESYS_SYSTEM_H
Expand All @@ -43,7 +43,9 @@ void Sys_Init(void);
void Sys_Shutdown(void);
void Sys_Quit(void);

int Sys_CriticalMessage(char* msg);
int Sys_CriticalMessage(const char* msg);
int Sys_CriticalMessagef(const char* format, ...) PRINTF_F(1,2);

void Sys_Sleep(int millisecs);
void Sys_ShowCursor(boolean show);
void Sys_HideMouse(void);
Expand Down

0 comments on commit 1b14462

Please sign in to comment.