- overbright = v_overbrightbits.integer;
- batch = false;
- batchcount = 0;
- for (pos = 0;pos < r_refdef.drawqueuesize;pos += ((drawqueue_t *)(r_refdef.drawqueue + pos))->size)
- {
- dq = (drawqueue_t *)(r_refdef.drawqueue + pos);
- if (dq->flags & DRAWFLAG_ADDITIVE)
- {
- if (!additive)
- {
- if (batch)
- {
- batch = false;
- qglEnd();
- }
- additive = true;
- qglBlendFunc(GL_SRC_ALPHA, GL_ONE);
- }
- }
- 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("conchars", currentpic))
- {
- if (batch)
- {
- batch = false;
- qglEnd();
- }
- currentpic = "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;