]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
added DrawQ_Line/DrawQ_Lines/DrawQ_LineWidth patch from [515], note: buggy, needs...
authorhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 Jan 2006 23:15:12 +0000 (23:15 +0000)
committerhavoc <havoc@d7cf8633-e32d-0410-b094-e92efae38249>
Wed, 11 Jan 2006 23:15:12 +0000 (23:15 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5900 d7cf8633-e32d-0410-b094-e92efae38249

cl_screen.c
cl_screen.h
gl_draw.c
glquake.h
vid_shared.c

index d7baa8b2a1f3d727d54c940adc106cee994dd59e..3e181fbdd2fdfdb1d0f6c8fb4415fdcefd39a405 100644 (file)
@@ -758,6 +758,86 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags)
        r_refdef.drawqueuesize += dq->size;
 }
 
+void DrawQ_Lines (drawqueuemesh_t *mesh, int flags)
+{
+       int size;
+       void *p;
+       drawqueue_t *dq;
+       drawqueuemesh_t *m;
+       size = sizeof(*dq);
+       size += sizeof(drawqueuemesh_t);
+       size += sizeof(int[3]) * mesh->num_triangles;
+       size += sizeof(float[3]) * mesh->num_vertices;
+       size += sizeof(float[2]) * mesh->num_vertices;
+       size += sizeof(float[4]) * mesh->num_vertices;
+       if (r_refdef.drawqueuesize + size > r_refdef.maxdrawqueuesize)
+               return;
+       dq = (void *)(r_refdef.drawqueue + r_refdef.drawqueuesize);
+       dq->size = size;
+       dq->command = DRAWQUEUE_LINES;
+       dq->flags = flags;
+       dq->color = 0;
+       dq->x = 0;
+       dq->y = 0;
+       dq->scalex = 0;
+       dq->scaley = 0;
+       p = (void *)(dq + 1);
+       m = p;p = (unsigned char*)p + sizeof(drawqueuemesh_t);
+       m->num_triangles = mesh->num_triangles;
+       m->num_vertices = mesh->num_vertices;
+       m->texture = mesh->texture;
+       m->data_element3i  = p;memcpy(m->data_element3i , mesh->data_element3i , m->num_triangles * sizeof(int[3]));p = (unsigned char*)p + m->num_triangles * sizeof(int[3]);
+       m->data_vertex3f   = p;memcpy(m->data_vertex3f  , mesh->data_vertex3f  , m->num_vertices * sizeof(float[3]));p = (unsigned char*)p + m->num_vertices * sizeof(float[3]);
+       m->data_texcoord2f = p;memcpy(m->data_texcoord2f, mesh->data_texcoord2f, m->num_vertices * sizeof(float[2]));p = (unsigned char*)p + m->num_vertices * sizeof(float[2]);
+       m->data_color4f    = p;memcpy(m->data_color4f   , mesh->data_color4f   , m->num_vertices * sizeof(float[4]));p = (unsigned char*)p + m->num_vertices * sizeof(float[4]);
+       r_refdef.drawqueuesize += dq->size;
+}
+
+//LordHavoc: FIXME: this is nasty!
+void DrawQ_LineWidth (float width)
+{
+       drawqueue_t *dq;
+       static int linewidth = 1;
+       if(width == linewidth)
+               return;
+       linewidth = width;
+       if(r_refdef.drawqueuesize + (int)sizeof(*dq) > r_refdef.maxdrawqueuesize)
+       {
+               Con_DPrint("DrawQueue full !\n");
+               return;
+       }
+       dq = (void*) (r_refdef.drawqueue + r_refdef.drawqueuesize);
+       dq->size = sizeof(*dq);
+       dq->command = DRAWQUEUE_LINEWIDTH;
+       dq->x = width;
+
+       r_refdef.drawqueuesize += dq->size;
+}
+
+//[515]: this is old, delete
+void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, float g, float b, float alpha, int flags)
+{
+       drawqueue_t *dq;
+       if(width > 0)
+               DrawQ_LineWidth(width);
+       if(r_refdef.drawqueuesize + (int)sizeof(*dq) > r_refdef.maxdrawqueuesize)
+       {
+               Con_DPrint("DrawQueue full !\n");
+               return;
+       }
+       dq = (void*) (r_refdef.drawqueue + r_refdef.drawqueuesize);
+       dq->size = sizeof(*dq);
+       dq->command = DRAWQUEUE_LINES;
+       dq->x = x1;
+       dq->y = y1;
+       dq->scalex = x2;
+       dq->scaley = y2;
+       dq->flags = flags;
+       dq->color =  ((unsigned int) (r * 255.0f) << 24) | ((unsigned int) (g * 255.0f) << 16) | ((unsigned int) (b * 255.0f) << 8) | ((unsigned int) (alpha * 255.0f));
+
+       r_refdef.drawqueuesize += dq->size;
+}
+
 void DrawQ_SetClipArea(float x, float y, float width, float height)
 {
        drawqueue_t * dq;
index a6bcb3524c450921fe590d1260b8b6ce50308d3f..d58d7642319c0a90a5ee85f3ca56d22a0f3c5aae 100644 (file)
@@ -7,6 +7,8 @@
 #define DRAWQUEUE_MESH 1
 #define DRAWQUEUE_SETCLIP 2
 #define DRAWQUEUE_RESETCLIP 3
+#define DRAWQUEUE_LINEWIDTH 4
+#define DRAWQUEUE_LINES 5
 
 typedef struct drawqueue_s
 {
@@ -64,6 +66,8 @@ void DrawQ_Mesh(drawqueuemesh_t *mesh, int flags);
 void DrawQ_SetClipArea(float x, float y, float width, float height);
 // reset the clipping area
 void DrawQ_ResetClipArea(void);
+// draw a line
+void DrawQ_Line(float width, float x1, float y1, float x2, float y2, float r, float g, float b, float alpha, int flags);
 
 void SHOWLMP_decodehide(void);
 void SHOWLMP_decodeshow(void);
index cbeefdcfce91a53ee31501c099a6037ace828108..40146424c1f108b4f39179df95ffd156ab09e3cd 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -657,6 +657,17 @@ void R_DrawQueue(void)
                case DRAWQUEUE_RESETCLIP:
                        GL_ScissorTest(false);
                        break;
+               case DRAWQUEUE_LINEWIDTH:
+                       qglLineWidth(x);
+                       break;
+               case DRAWQUEUE_LINES:
+                       mesh = (drawqueuemesh_t *)(dq + 1);
+                       GL_Color(c[0], c[1], c[2], c[3]);
+                       qglBegin(GL_LINE_LOOP);
+                       for (num = 0;num < mesh->num_vertices;num++)
+                               qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
+                       qglEnd();
+                       break;
                }
        }
 
index 764fe465c2a385ca6862017a8eaab002770e1395..f8066af5a2977d321e024eda3c97fb046a2739f8 100644 (file)
--- a/glquake.h
+++ b/glquake.h
@@ -495,6 +495,10 @@ extern void (GLAPIENTRY *qglCopyTexSubImage2D)(GLenum target, GLint level, GLint
 
 extern void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
 
+//[515]: added on 29.07.2005
+extern void (GLAPIENTRY *qglLineWidth)(GLfloat width);
+extern void (GLAPIENTRY *qglPointSize)(GLfloat size);
+
 // GL_ARB_shader_objects
 extern int gl_support_shader_objects;
 #ifndef GL_PROGRAM_OBJECT_ARB
index b5cee08104107ba23c405a4a81222e1b7662922f..b47348ee2afa68f4411b74b3fabcc3391e8620fe 100644 (file)
@@ -248,6 +248,10 @@ void (GLAPIENTRY *qglScissor)(GLint x, GLint y, GLsizei width, GLsizei height);
 
 void (GLAPIENTRY *qglPolygonOffset)(GLfloat factor, GLfloat units);
 
+//[515]: added on 29.07.2005
+void (GLAPIENTRY *qglLineWidth)(GLfloat width);
+void (GLAPIENTRY *qglPointSize)(GLfloat size);
+
 void (GLAPIENTRY *qglActiveStencilFaceEXT)(GLenum);
 
 void (GLAPIENTRY *qglDeleteObjectARB)(GLhandleARB obj);
@@ -420,6 +424,10 @@ static dllfunction_t opengl110funcs[] =
        {"glVertex3f", (void **) &qglVertex3f},
        {"glBegin", (void **) &qglBegin},
        {"glEnd", (void **) &qglEnd},
+//[515]: added on 29.07.2005
+       {"glLineWidth", (void**) &qglLineWidth},
+       {"glPointSize", (void**) &qglPointSize},
+//
        {"glMatrixMode", (void **) &qglMatrixMode},
        {"glOrtho", (void **) &qglOrtho},
        {"glFrustum", (void **) &qglFrustum},