funky interlacing-like rendering feature from div0 (scr_stipple cvar)
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Nov 2006 23:51:51 +0000 (23:51 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Thu, 30 Nov 2006 23:51:51 +0000 (23:51 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6628 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
glquake.h
vid_shared.c

index 6f9fd9a..e806e45 100644 (file)
@@ -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");
 
index 02a955e..47cb698 100644 (file)
--- 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
index 8bd1851..6a2d0d2 100644 (file)
@@ -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}
 };