Skip to content

Commit

Permalink
Switched to OpenGL 3.3 Core Profile; old GL code should use DGL
Browse files Browse the repository at this point in the history
The DGL functions approximate old OpenGL 1.x fixed-function drawing
for legacy code.
  • Loading branch information
skyjake committed Apr 21, 2017
1 parent 15a1c83 commit 2359abb
Show file tree
Hide file tree
Showing 48 changed files with 1,328 additions and 1,331 deletions.
14 changes: 5 additions & 9 deletions doomsday/apps/api/api_gl.h
Expand Up @@ -119,6 +119,8 @@ typedef enum dgltexformat_e {
/// Primitive types.
typedef enum dglprimtype_e {
DGL_LINES,
DGL_LINE_STRIP,
DGL_LINE_LOOP,
DGL_TRIANGLES,
DGL_TRIANGLE_FAN,
DGL_TRIANGLE_STRIP,
Expand Down Expand Up @@ -259,17 +261,14 @@ DENG_API_TYPEDEF(GL)
void (*PushMatrix)(void);
void (*PopMatrix)(void);
void (*LoadIdentity)(void);
void (*LoadMatrix)(float const *matrix4x4);

void (*Translatef)(float x, float y, float z);
void (*Rotatef)(float angle, float x, float y, float z);
void (*Scalef)(float x, float y, float z);

void (*Begin)(dglprimtype_t type);
void (*End)(void);
dd_bool (*NewList)(DGLuint list, int mode);
DGLuint (*EndList)(void);
void (*CallList)(DGLuint list);
void (*DeleteLists)(DGLuint list, int range);

void (*SetNoMaterial)(void);
void (*SetMaterialUI)(world_Material *mat, DGLint wrapS, DGLint wrapT);
Expand All @@ -292,7 +291,7 @@ DENG_API_TYPEDEF(GL)
void (*Color4fv)(const float* vec);

void (*TexCoord2f)(byte target, float s, float t);
void (*TexCoord2fv)(byte target, float* vec);
void (*TexCoord2fv)(byte target, float const *vec);

void (*Vertex2f)(float x, float y);
void (*Vertex2fv)(const float* vec);
Expand Down Expand Up @@ -365,15 +364,12 @@ DENG_API_T(GL);
#define DGL_PushMatrix _api_GL.PushMatrix
#define DGL_PopMatrix _api_GL.PopMatrix
#define DGL_LoadIdentity _api_GL.LoadIdentity
#define DGL_LoadMatrix _api_GL.LoadMatrix
#define DGL_Translatef _api_GL.Translatef
#define DGL_Rotatef _api_GL.Rotatef
#define DGL_Scalef _api_GL.Scalef
#define DGL_Begin _api_GL.Begin
#define DGL_End _api_GL.End
#define DGL_NewList _api_GL.NewList
#define DGL_EndList _api_GL.EndList
#define DGL_CallList _api_GL.CallList
#define DGL_DeleteLists _api_GL.DeleteLists
#define DGL_SetNoMaterial _api_GL.SetNoMaterial
#define DGL_SetMaterialUI _api_GL.SetMaterialUI
#define DGL_SetPatch _api_GL.SetPatch
Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/api/apis.h
Expand Up @@ -106,7 +106,8 @@ enum {
DE_API_GL_v1 = 800, // 1.10
DE_API_GL_v2 = 801, // 1.13
DE_API_GL_v3 = 802, // 1.15
DE_API_GL = DE_API_GL_v3,
DE_API_GL_v4 = 803, // 2.1
DE_API_GL = DE_API_GL_v4,

DE_API_INFINE_v1 = 900, // 1.10
DE_API_INFINE = DE_API_INFINE_v1,
Expand Down
17 changes: 2 additions & 15 deletions doomsday/apps/client/include/gl/sys_opengl.h
Expand Up @@ -91,8 +91,8 @@ typedef struct gl_state_s {
/// Feature (abstract) availability bits:
/// Vendor and implementation agnostic.
struct {
uint blendSubtract : 1;
uint genMipmap : 1;
//uint blendSubtract : 1;
//uint genMipmap : 1;
uint texCompression : 1;
uint texFilterAniso : 1;
} features;
Expand All @@ -119,19 +119,6 @@ extern "C" {

extern gl_state_t GL_state;

/*#ifdef WIN32
//extern PFNWGLSWAPINTERVALEXTPROC wglSwapIntervalEXT;
extern PFNWGLCHOOSEPIXELFORMATARBPROC wglChoosePixelFormatARB;
#endif
*/
/*
#if defined(LIBGUI_USE_GLENTRYPOINTS)
extern PFNGLBLENDEQUATIONEXTPROC glBlendEquationEXT;
extern PFNGLLOCKARRAYSEXTPROC glLockArraysEXT;
extern PFNGLUNLOCKARRAYSEXTPROC glUnlockArraysEXT;
#endif
*/

#ifndef GL_ATI_texture_env_combine3
#define GL_MODULATE_ADD_ATI 0x8744
#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
Expand Down
18 changes: 9 additions & 9 deletions doomsday/apps/client/src/audio/sfxchannel.cpp
Expand Up @@ -449,12 +449,12 @@ void Sfx_ChannelDrawer()
DENG_ASSERT_GL_CONTEXT_ACTIVE();

// Go into screen projection mode.
LIBGUI_GL.glMatrixMode(GL_PROJECTION);
LIBGUI_GL.glPushMatrix();
LIBGUI_GL.glLoadIdentity();
LIBGUI_GL.glOrtho(0, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT, 0, -1, 1);
DGL_MatrixMode(DGL_PROJECTION);
DGL_PushMatrix();
DGL_LoadIdentity();
DGL_Ortho(0, DENG_GAMEVIEW_WIDTH, DENG_GAMEVIEW_HEIGHT, 0, -1, 1);

LIBGUI_GL.glEnable(GL_TEXTURE_2D);
DGL_Enable(DGL_TEXTURE_2D);

FR_SetFont(fontFixed);
FR_LoadDefaultAttrib();
Expand All @@ -464,7 +464,7 @@ void Sfx_ChannelDrawer()
if(!App_AudioSystem().sfxIsAvailable())
{
FR_DrawTextXY("Sfx disabled", 0, 0);
LIBGUI_GL.glDisable(GL_TEXTURE_2D);
DGL_Disable(DGL_TEXTURE_2D);
return;
}

Expand Down Expand Up @@ -532,9 +532,9 @@ void Sfx_ChannelDrawer()
return LoopContinue;
});

LIBGUI_GL.glDisable(GL_TEXTURE_2D);
DGL_Disable(DGL_TEXTURE_2D);

// Back to the original.
LIBGUI_GL.glMatrixMode(GL_PROJECTION);
LIBGUI_GL.glPopMatrix();
DGL_MatrixMode(DGL_PROJECTION);
DGL_PopMatrix();
}
50 changes: 28 additions & 22 deletions doomsday/apps/client/src/gl/dgl_common.cpp
Expand Up @@ -38,6 +38,7 @@

using namespace de;

#if 0
/**
* Requires a texture environment mode that can add and multiply.
* Nvidia's and ATI's appropriate extensions are supported, other cards will
Expand Down Expand Up @@ -113,15 +114,20 @@ static void envModMultiTex(int activate)
// This is a single-pass mode. The alpha should remain unmodified
// during the light stage.
if(activate)
{ // Replace: primAlpha.
{
// Replace: primAlpha.
LIBGUI_GL.glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
LIBGUI_GL.glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_PREVIOUS);
LIBGUI_GL.glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
}
}
#endif

void GL_ModulateTexture(int mode)
{
qDebug() << "GL_ModulateTexture: TexEnv not available; mode" << mode;

#if 0
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

Expand Down Expand Up @@ -305,6 +311,7 @@ void GL_ModulateTexture(int mode)
default:
break;
}
#endif
}

/*void GL_BlendOp(int op)
Expand Down Expand Up @@ -375,7 +382,8 @@ dd_bool DGL_GetIntegerv(int name, int *v)
switch(name)
{
case DGL_MODULATE_ADD_COMBINE:
*v = GLInfo::extensions().NV_texture_env_combine4 || GLInfo::extensions().ATI_texture_env_combine3;
qDebug() << "DGL_GetIntegerv: tex env not available";
//*v = GLInfo::extensions().NV_texture_env_combine4 || GLInfo::extensions().ATI_texture_env_combine3;
break;

case DGL_SCISSOR_TEST:
Expand Down Expand Up @@ -675,9 +683,9 @@ void DGL_MatrixMode(int mode)
DENG_ASSERT_GL_CONTEXT_ACTIVE();
DENG_ASSERT(mode == DGL_PROJECTION || mode == DGL_TEXTURE || mode == DGL_MODELVIEW);

LIBGUI_GL.glMatrixMode(mode == DGL_PROJECTION ? GL_PROJECTION :
mode == DGL_TEXTURE ? GL_TEXTURE :
GL_MODELVIEW);
// LIBGUI_GL.glMatrixMode(mode == DGL_PROJECTION ? GL_PROJECTION :
// mode == DGL_TEXTURE ? GL_TEXTURE :
// GL_MODELVIEW);
}

#undef DGL_PushMatrix
Expand All @@ -686,7 +694,7 @@ void DGL_PushMatrix(void)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glPushMatrix();
DGL_PushMatrix();

#if _DEBUG
if(LIBGUI_GL.glGetError() == GL_STACK_OVERFLOW)
Expand Down Expand Up @@ -768,12 +776,7 @@ void DGL_PopMatrix(void)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glPopMatrix();

#if _DEBUG
if(LIBGUI_GL.glGetError() == GL_STACK_UNDERFLOW)
App_Error("DG_PopMatrix: Stack underflow.\n");
#endif
//DGL_PopMatrix();
}

#undef DGL_LoadIdentity
Expand All @@ -782,7 +785,13 @@ void DGL_LoadIdentity(void)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glLoadIdentity();
//DGL_LoadIdentity();
}

#undef DGL_LoadMatrix
void DGL_LoadMatrix(float const *matrix4x4)
{
// TODO: replace matrix in stack
}

#undef DGL_Translatef
Expand All @@ -791,7 +800,7 @@ void DGL_Translatef(float x, float y, float z)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glTranslatef(x, y, z);
//DGL_Translatef(x, y, z);
}

#undef DGL_Rotatef
Expand All @@ -800,7 +809,7 @@ void DGL_Rotatef(float angle, float x, float y, float z)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glRotatef(angle, x, y, z);
//DGL_Rotatef(angle, x, y, z);
}

#undef DGL_Scalef
Expand All @@ -809,7 +818,7 @@ void DGL_Scalef(float x, float y, float z)
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glScalef(x, y, z);
//DGL_Scalef(x, y, z);
}

#undef DGL_Ortho
Expand All @@ -818,7 +827,7 @@ void DGL_Ortho(float left, float top, float right, float bottom, float znear, fl
DENG_ASSERT_IN_MAIN_THREAD();
DENG_ASSERT_GL_CONTEXT_ACTIVE();

LIBGUI_GL.glOrtho(left, right, bottom, top, znear, zfar);
//DGL_Ortho(left, right, bottom, top, znear, zfar);
}

#undef DGL_DeleteTextures
Expand Down Expand Up @@ -873,7 +882,7 @@ DENG_EXTERN_C void DGL_Color3fv(const float* vec);
DENG_EXTERN_C void DGL_Color4f(float r, float g, float b, float a);
DENG_EXTERN_C void DGL_Color4fv(const float* vec);
DENG_EXTERN_C void DGL_TexCoord2f(byte target, float s, float t);
DENG_EXTERN_C void DGL_TexCoord2fv(byte target, float* vec);
DENG_EXTERN_C void DGL_TexCoord2fv(byte target, float const *vec);
DENG_EXTERN_C void DGL_Vertex2f(float x, float y);
DENG_EXTERN_C void DGL_Vertex2fv(const float* vec);
DENG_EXTERN_C void DGL_Vertex3f(float x, float y, float z);
Expand Down Expand Up @@ -923,15 +932,12 @@ DENG_DECLARE_API(GL) =
DGL_PushMatrix,
DGL_PopMatrix,
DGL_LoadIdentity,
DGL_LoadMatrix,
DGL_Translatef,
DGL_Rotatef,
DGL_Scalef,
DGL_Begin,
DGL_End,
DGL_NewList,
DGL_EndList,
DGL_CallList,
DGL_DeleteLists,
DGL_SetNoMaterial,
DGL_SetMaterialUI,
DGL_SetPatch,
Expand Down

0 comments on commit 2359abb

Please sign in to comment.