+ else
+ {
+ if (additive)
+ {
+ if (batch)
+ {
+ batch = false;
+ qglEnd();
+ }
+ additive = false;
+ qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ }
+ }
+ if (color != dq->color)
+ {
+ color = dq->color;
+ qglColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
+ }
+ if (batch && batchcount > 128)
+ {
+ batch = false;
+ qglEnd();
+ }
+ x = dq->x;
+ y = dq->y;
+ w = dq->scalex;
+ h = dq->scaley;
+ switch(dq->command)
+ {
+ case DRAWQUEUE_PIC:
+ str = (char *)(dq + 1);
+ if (*str)
+ {
+ if (strcmp(str, currentpic))
+ {
+ if (batch)
+ {
+ batch = false;
+ qglEnd();
+ }
+ currentpic = str;
+ pic = Draw_CachePic(str);
+ qglBindTexture(GL_TEXTURE_2D, R_GetTexture(pic->tex));
+ }
+ if (w == 0)
+ w = pic->width;
+ if (h == 0)
+ h = pic->height;
+ if (!batch)
+ {
+ batch = true;
+ qglBegin(GL_TRIANGLES);
+ batchcount = 0;
+ }
+ qglTexCoord2f (0, 0);qglVertex2f (x , y );
+ qglTexCoord2f (1, 0);qglVertex2f (x+w, y );
+ qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (0, 0);qglVertex2f (x , y );
+ qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (0, 1);qglVertex2f (x , y+h);
+ batchcount++;
+ }
+ else
+ {
+ if (currentpic[0])
+ {
+ if (batch)
+ {
+ batch = false;
+ qglEnd();
+ }
+ currentpic = "";
+ qglBindTexture(GL_TEXTURE_2D, 0);
+ }
+ if (!batch)
+ {
+ batch = true;
+ qglBegin(GL_TRIANGLES);
+ batchcount = 0;
+ }
+ qglTexCoord2f (0, 0);qglVertex2f (x , y );
+ qglTexCoord2f (1, 0);qglVertex2f (x+w, y );
+ qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (0, 0);qglVertex2f (x , y );
+ qglTexCoord2f (1, 1);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (0, 1);qglVertex2f (x , y+h);
+ batchcount++;
+ }
+ break;
+ case DRAWQUEUE_STRING:
+ str = (char *)(dq + 1);
+ if (strcmp("gfx/conchars", currentpic))
+ {
+ if (batch)
+ {
+ batch = false;
+ qglEnd();
+ }
+ currentpic = "gfx/conchars";
+ qglBindTexture(GL_TEXTURE_2D, chartexnum);
+ }
+ if (!batch)
+ {
+ batch = true;
+ qglBegin(GL_TRIANGLES);
+ batchcount = 0;
+ }
+ while ((num = *str++) && x < vid.conwidth)
+ {
+ if (num != ' ')
+ {
+ s = (num & 15)*0.0625f + (0.5f / 256.0f);
+ t = (num >> 4)*0.0625f + (0.5f / 256.0f);
+ u = 0.0625f - (1.0f / 256.0f);
+ v = 0.0625f - (1.0f / 256.0f);
+ qglTexCoord2f (s , t );qglVertex2f (x , y );
+ qglTexCoord2f (s+u, t );qglVertex2f (x+w, y );
+ qglTexCoord2f (s+u, t+v);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (s , t );qglVertex2f (x , y );
+ qglTexCoord2f (s+u, t+v);qglVertex2f (x+w, y+h);
+ qglTexCoord2f (s , t+v);qglVertex2f (x , y+h);
+ batchcount++;
+ }
+ x += w;
+ }
+ break;
+ case DRAWQUEUE_MESH:
+ if (batch)
+ {
+ batch = false;
+ qglEnd();
+ }
+
+ mesh = (void *)(dq + 1);
+ qglBindTexture(GL_TEXTURE_2D, R_GetTexture(mesh->texture));
+ qglVertexPointer(3, GL_FLOAT, sizeof(float[4]), mesh->vertices);CHECKGLERROR
+ qglTexCoordPointer(2, GL_FLOAT, sizeof(float[2]), mesh->texcoords);CHECKGLERROR
+ qglColorPointer(4, GL_FLOAT, sizeof(float[4]), mesh->colors);CHECKGLERROR
+ qglEnableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
+ qglEnableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ qglEnableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+ GL_DrawRangeElements(0, mesh->numvertices, mesh->numindices, mesh->indices);
+ qglDisableClientState(GL_VERTEX_ARRAY);CHECKGLERROR
+ qglDisableClientState(GL_TEXTURE_COORD_ARRAY);CHECKGLERROR
+ qglDisableClientState(GL_COLOR_ARRAY);CHECKGLERROR
+
+ // restore color, since it got trashed by using color array
+ qglColor4ub((qbyte)(((color >> 24) & 0xFF) >> overbright), (qbyte)(((color >> 16) & 0xFF) >> overbright), (qbyte)(((color >> 8) & 0xFF) >> overbright), (qbyte)(color & 0xFF));
+ CHECKGLERROR
+ currentpic = "\0";
+ break;
+ }
+ }
+ if (batch)
+ qglEnd();
+ CHECKGLERROR