Skip to content

Commit

Permalink
Added support for changing the GL_LINE_SMOOTH environment variable fo…
Browse files Browse the repository at this point in the history
…r antialiased line drawing and variable line widths. GL_LINE_SMOOTH is now enabled by default.
  • Loading branch information
danij committed Dec 15, 2007
1 parent f5bf3a8 commit 3393f7f
Show file tree
Hide file tree
Showing 7 changed files with 181 additions and 50 deletions.
12 changes: 8 additions & 4 deletions doomsday/plugins/debugrenderer/api/drdebug.def
Expand Up @@ -12,10 +12,14 @@ EXPORTS
DG_Show
DG_Viewport
DG_Scissor
DG_GetInteger
DG_GetIntegerv
DG_SetInteger
DG_SetFloatv
DG_GetInteger
DG_GetIntegerv
DG_SetInteger
DG_SetIntegerv
DG_GetFloat
DG_GetFloatv
DG_SetFloat
DG_SetFloatv
DG_GetString
DG_Enable
DG_Disable
Expand Down
55 changes: 50 additions & 5 deletions doomsday/plugins/debugrenderer/src/main.c
Expand Up @@ -4,6 +4,7 @@
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2007 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2007 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -17,11 +18,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

/*
/**
* main.c: Debugging Layer for the Doomsday Rendering DLLs
*
* The real rendering DLL can be specified using the -dgl option.
Expand All @@ -35,8 +36,8 @@
#include "doomsday.h"
#include "..\..\..\engine\portable\include\dd_dgl.h"

/*
* This macro is used to import all the exported functions from the
/*
* This macro is used to import all the exported functions from the
* rendering DLL.
*/
#define Imp(fname) (gl.fname = (void*) GetProcAddress(dglInstance, "DG_"#fname))
Expand Down Expand Up @@ -91,6 +92,10 @@ BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Imp(GetInteger);
Imp(GetIntegerv);
Imp(SetInteger);
Imp(SetIntegerv);
Imp(GetFloat);
Imp(GetFloatv);
Imp(SetFloat);
Imp(SetFloatv);
Imp(GetString);
Imp(Enable);
Expand All @@ -100,7 +105,7 @@ BOOL __stdcall DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
Imp(Arrays);
Imp(UnlockArrays);
Imp(Func);
//Imp(ZBias);
//Imp(ZBias);

// Textures.
Imp(NewTexture);
Expand Down Expand Up @@ -321,6 +326,16 @@ int DG_SetInteger(int name, int value)
return result;
}

int DG_SetIntegerv(int name, const int *values)
{
int result;

in(1, "SetIntegerv (0x%x, 0x%p)", name, values);
result = gl.SetIntegerv(name, values);
out(1, "SetIntegerv: %i", result);
return result;
}

char *DG_GetString(int name)
{
char *result;
Expand All @@ -331,6 +346,36 @@ char *DG_GetString(int name)
return result;
}

float DG_GetFloat(int name)
{
float result;

in(1, "GetFloat (0x%x)", name);
result = gl.GetFloat(name);
out(1, "GetFloat: %g", result);
return result;
}

int DG_SetFloat(int name, float value)
{
int result;

in(1, "SetFloat (0x%x, %g)", name, value);
result = gl.SetFloat(name, value);
out(1, "SetFloat: %i", result);
return result;
}

int DG_GetFloatv(int name, float *v)
{
int result;

in(1, "GetFloatv (0x%x, 0x%p)", name, v);
result = gl.GetFloatv(name, v);
out(1, "GetFloatv: %i, %g", result, v[0]);
return result;
}

int DG_SetFloatv(int name, const float *values)
{
int result;
Expand Down
4 changes: 4 additions & 0 deletions doomsday/plugins/opengl/api/dropengl.def
Expand Up @@ -15,6 +15,10 @@ EXPORTS
DG_GetInteger
DG_GetIntegerv
DG_SetInteger
DG_SetIntegerv
DG_GetFloat
DG_GetFloatv
DG_SetFloat
DG_SetFloatv
DG_GetString
DG_Enable
Expand Down
98 changes: 87 additions & 11 deletions doomsday/plugins/opengl/portable/src/common.c
Expand Up @@ -18,11 +18,11 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

/*
/**
* common.c : Portable OpenGL init/state routines.
*/

Expand Down Expand Up @@ -54,11 +54,14 @@ int useFog;

// PRIVATE DATA DEFINITIONS ------------------------------------------------

static float currentLineWidth;

// CODE --------------------------------------------------------------------

void initState(void)
{
GLfloat fogcol[4] = { .54f, .54f, .54f, 1 };
GLfloat fogcol[4] = { .54f, .54f, .54f, 1 };
GLfloat values[2];

nearClip = 5;
farClip = 8000;
Expand Down Expand Up @@ -92,6 +95,19 @@ void initState(void)
glMatrixMode(GL_TEXTURE);
glLoadIdentity();

// Setup for antialiased lines/points.
glGetFloatv(GL_LINE_WIDTH_GRANULARITY, values);
Con_Message(" GL_LINE_WIDTH_GRANULARITY: %3.1f\n",
values[0]);
glGetFloatv(GL_LINE_WIDTH_RANGE, values);
Con_Message(" GL_LINE_WIDTH_RANGE: %3.1f %3.1f\n",
values[0], values[1]);

glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
currentLineWidth = 1.5f;
glLineWidth(currentLineWidth);

// Alpha blending is a go!
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Expand Down Expand Up @@ -318,7 +334,7 @@ int DG_GetIntegerv(int name, int *v)
case DGL_GRAY_MIPMAP:
*v = (int) (grayMipmapFactor * 255);
break;

default:
return DGL_ERROR;
}
Expand Down Expand Up @@ -356,13 +372,13 @@ int DG_SetInteger(int name, int value)
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
else if(value == 12)
{ // Normal texture modulation on both stages. TU 1 modulates with
{ // Normal texture modulation on both stages. TU 1 modulates with
// primary color, TU 2 with TU 1.
activeTexture(GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
activeTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
}
}
else if(value == 2 || value == 3)
{ // Texture modulation and interpolation.
activeTexture(GL_TEXTURE1);
Expand Down Expand Up @@ -531,6 +547,17 @@ int DG_SetInteger(int name, int value)
return DGL_OK;
}

int DG_SetIntegerv(int name, const int *values)
{
switch(name)
{
default:
return DGL_ERROR;
}

return DGL_OK;
}

char *DG_GetString(int name)
{
switch(name)
Expand All @@ -542,7 +569,48 @@ char *DG_GetString(int name)
return NULL;
}

int DG_SetFloatv(int name, float *values)
float DG_GetFloat(int name)
{
switch(name)
{
case DGL_LINE_WIDTH:
return currentLineWidth;

default:
return DGL_ERROR;
}

return DGL_OK;
}

int DG_GetFloatv(int name, float *values)
{
switch(name)
{
default:
return DGL_ERROR;
}

return DGL_OK;
}

int DG_SetFloat(int name, float value)
{
switch(name)
{
case DGL_LINE_WIDTH:
currentLineWidth = value;
glLineWidth(value);
break;

default:
return DGL_ERROR;
}

return DGL_OK;
}

int DG_SetFloatv(int name, const float *values)
{
switch(name)
{
Expand All @@ -559,7 +627,7 @@ int DG_SetFloatv(int name, float *values)

int DG_Enable(int cap)
{
switch (cap)
switch(cap)
{
case DGL_TEXTURING:
#ifndef DRMESA
Expand Down Expand Up @@ -625,12 +693,16 @@ int DG_Enable(int cap)
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
break;

case DGL_LINE_SMOOTH:
glEnable(GL_LINE_SMOOTH);
break;

case DGL_VSYNC:
if(extVSync)
{
#ifdef WIN32
wglSwapIntervalEXT(1);
#endif
#endif
useVSync = DGL_TRUE;
}
break;
Expand Down Expand Up @@ -714,12 +786,16 @@ void DG_Disable(int cap)
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
break;

case DGL_LINE_SMOOTH:
glDisable(GL_LINE_SMOOTH);
break;

case DGL_VSYNC:
if(extVSync)
{
#ifdef WIN32
#ifdef WIN32
wglSwapIntervalEXT(0);
#endif
#endif
useVSync = DGL_FALSE;
}
break;
Expand Down

0 comments on commit 3393f7f

Please sign in to comment.