From 26167511a978ab0ab7fb342af6a52f86fef3151b Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 30 Nov 2006 23:51:51 +0000 Subject: [PATCH] funky interlacing-like rendering feature from div0 (scr_stipple cvar) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6628 d7cf8633-e32d-0410-b094-e92efae38249 --- cl_screen.c | 24 ++++++++++++++++++++++++ glquake.h | 4 ++++ vid_shared.c | 2 ++ 3 files changed, 30 insertions(+) diff --git a/cl_screen.c b/cl_screen.c index 6f9fd9a1..e806e45a 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -43,6 +43,7 @@ cvar_t scr_zoomwindow = {CVAR_SAVE, "scr_zoomwindow", "0", "displays a zoomed in cvar_t scr_zoomwindow_viewsizex = {CVAR_SAVE, "scr_zoomwindow_viewsizex", "20", "horizontal viewsize of zoom window"}; cvar_t scr_zoomwindow_viewsizey = {CVAR_SAVE, "scr_zoomwindow_viewsizey", "20", "vertical viewsize of zoom window"}; cvar_t scr_zoomwindow_fov = {CVAR_SAVE, "scr_zoomwindow_fov", "20", "fov of zoom window"}; +cvar_t scr_stipple = {0, "scr_stipple", "0", "interlacing-like stippling of the display"}; int jpeg_supported = false; @@ -612,6 +613,7 @@ void CL_Screen_Init(void) Cvar_RegisterVariable(&scr_zoomwindow_viewsizex); Cvar_RegisterVariable(&scr_zoomwindow_viewsizey); Cvar_RegisterVariable(&scr_zoomwindow_fov); + Cvar_RegisterVariable(&scr_stipple); Cmd_AddCommand ("sizeup",SCR_SizeUp_f, "increase view size (increases viewsize cvar)"); Cmd_AddCommand ("sizedown",SCR_SizeDown_f, "decrease view size (decreases viewsize cvar)"); @@ -1739,6 +1741,28 @@ void CL_UpdateScreen(void) qglClearColor(0,0,0,0);CHECKGLERROR qglClear(GL_COLOR_BUFFER_BIT);CHECKGLERROR + if(scr_stipple.integer) + { + GLubyte stipple[128]; + int i, s, width, parts; + static int frame = 0; + ++frame; + + s = scr_stipple.integer; + parts = (s & 007); + width = (s & 070) >> 3; + + qglEnable(GL_POLYGON_STIPPLE); // 0x0B42 + for(i = 0; i < 128; ++i) + { + int line = i/4; + stipple[i] = (((line >> width) + frame) & ((1 << parts) - 1)) ? 0x00 : 0xFF; + } + qglPolygonStipple(stipple); + } + else + qglDisable(GL_POLYGON_STIPPLE); + if (r_timereport_active) R_TimeReport("clear"); diff --git a/glquake.h b/glquake.h index 02a955eb..47cb698b 100644 --- a/glquake.h +++ b/glquake.h @@ -239,6 +239,9 @@ extern int gl_max_anisotropy; #define GL_POINT_SMOOTH 0x0B10 #define GL_LINE_SMOOTH 0x0B20 #define GL_POLYGON_SMOOTH 0x0B41 + +#define GL_POLYGON_STIPPLE 0x0B42 + #endif extern int gl_max_texture_size; @@ -553,6 +556,7 @@ extern void (GLAPIENTRY *qglGetActiveUniformARB)(GLhandleARB programObj, GLuint extern void (GLAPIENTRY *qglGetUniformfvARB)(GLhandleARB programObj, GLint location, GLfloat *params); extern void (GLAPIENTRY *qglGetUniformivARB)(GLhandleARB programObj, GLint location, GLint *params); extern void (GLAPIENTRY *qglGetShaderSourceARB)(GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source); +extern void (GLAPIENTRY *qglPolygonStipple)(const GLubyte *mask); #ifndef GL_PROGRAM_OBJECT_ARB #define GL_PROGRAM_OBJECT_ARB 0x8B40 #define GL_OBJECT_TYPE_ARB 0x8B4E diff --git a/vid_shared.c b/vid_shared.c index 8bd1851e..6a2d0d2c 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -240,6 +240,7 @@ void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height); void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units); void (GLAPIENTRY *qglPolygonMode)(GLenum face, GLenum mode); +void (GLAPIENTRY *qglPolygonStipple)(const GLubyte *mask); //[515]: added on 29.07.2005 void (GLAPIENTRY *qglLineWidth)(GLfloat width); @@ -468,6 +469,7 @@ static dllfunction_t opengl110funcs[] = {"glScissor", (void **) &qglScissor}, {"glPolygonOffset", (void **) &qglPolygonOffset}, {"glPolygonMode", (void **) &qglPolygonMode}, + {"glPolygonStipple", (void **) &qglPolygonStipple}, {NULL, NULL} }; -- 2.39.2