if(!((pic->texflags ^ texflags) & ~(TEXF_COMPRESS))) // ignore TEXF_COMPRESS when comparing, because fallback pics remove the flag
{
if(!(cachepicflags & CACHEPICFLAG_NOTPERSISTENT))
- pic->autoload = false; // persist it
+ {
+ if(pic->tex)
+ pic->autoload = false; // persist it
+ else
+ goto reload; // load it below, and then persist
+ }
return pic;
}
pic->chain = cachepichash[hashkey];
cachepichash[hashkey] = pic;
+reload:
// check whether it is an dynamic texture (if so, we can directly use its texture handler)
pic->tex = CL_GetDynTexture( path );
// if so, set the width/height, too
pic->autoload = (cachepicflags & CACHEPICFLAG_NOTPERSISTENT);
// load a high quality image from disk if possible
- pixels = loadimagepixelsbgra(path, false, true, r_texture_convertsRGB_2d.integer != 0, NULL);
+ pixels = loadimagepixelsbgra(path, false, true, r_texture_convertsRGB_2d.integer, NULL);
if (pixels == NULL && !strncmp(path, "gfx/", 4))
- pixels = loadimagepixelsbgra(path+4, false, true, r_texture_convertsRGB_2d.integer != 0, NULL);
+ pixels = loadimagepixelsbgra(path+4, false, true, r_texture_convertsRGB_2d.integer, NULL);
if (pixels)
{
pic->hasalpha = false;
{
if (pic->autoload && !pic->tex)
{
- pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, r_texture_convertsRGB_2d.integer != 0);
+ pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, r_texture_convertsRGB_2d.integer);
if (pic->tex == NULL && !strncmp(pic->name, "gfx/", 4))
- pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, r_texture_convertsRGB_2d.integer != 0);
+ pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, r_texture_convertsRGB_2d.integer);
if (pic->tex == NULL)
pic->tex = draw_generatepic(pic->name, true);
}
extern cvar_t developer_font;
dp_font_t *FindFont(const char *title, qboolean allocate_new)
{
- int i;
+ int i, oldsize;
// find font
for(i = 0; i < dp_fonts.maxsize; ++i)
}
}
// if no any 'free' fonts - expand buffer
- i = dp_fonts.maxsize;
+ oldsize = dp_fonts.maxsize;
dp_fonts.maxsize = dp_fonts.maxsize + FONTS_EXPAND;
if (developer_font.integer)
- Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", i, dp_fonts.maxsize);
+ Con_Printf("FindFont: enlarging fonts buffer (%i -> %i)\n", oldsize, dp_fonts.maxsize);
dp_fonts.f = (dp_font_t *)Mem_Realloc(fonts_mempool, dp_fonts.f, sizeof(dp_font_t) * dp_fonts.maxsize);
+ // relink ft2 structures
+ for(i = 0; i < oldsize; ++i)
+ if (dp_fonts.f[i].ft2)
+ dp_fonts.f[i].ft2->settings = &dp_fonts.f[i].settings;
// register a font in first expanded slot
- strlcpy(dp_fonts.f[i].title, title, sizeof(dp_fonts.f[i].title));
- return &dp_fonts.f[i];
+ strlcpy(dp_fonts.f[oldsize].title, title, sizeof(dp_fonts.f[oldsize].title));
+ return &dp_fonts.f[oldsize];
}
return NULL;
}
voffset = atof(Cmd_Argv(i));
continue;
}
+
+ if (sizes == -1)
+ continue; // no slot for other sizes
+
// parse one of sizes
sz = atof(Cmd_Argv(i));
if (sz > 0.001f && sz < 1000.0f) // do not use crap sizes
{
+ // search for duplicated sizes
+ int j;
+ for (j=0; j<sizes; j++)
+ if (f->req_sizes[j] == sz)
+ break;
+ if (j != sizes)
+ continue; // sz already in req_sizes, don't add it again
+
+ if (sizes == MAX_FONT_SIZES)
+ {
+ Con_Printf("Warning: specified more than %i different font sizes, exceding ones are ignored\n", MAX_FONT_SIZES);
+ sizes = -1;
+ continue;
+ }
f->req_sizes[sizes] = sz;
sizes++;
}
// allocate fonts storage
fonts_mempool = Mem_AllocPool("FONTS", 0, NULL);
dp_fonts.maxsize = MAX_FONTS;
- dp_fonts.f = (dp_font_t *)Mem_Alloc(fonts_mempool, sizeof(dp_font_t) * dp_fonts.maxsize);
+ dp_fonts.f = Mem_Alloc(fonts_mempool, sizeof(dp_font_t) * dp_fonts.maxsize);
memset(dp_fonts.f, 0, sizeof(dp_font_t) * dp_fonts.maxsize);
// assign starting font names
R_Viewport_InitOrtho(&viewport, &identitymatrix, r_refdef.view.x, vid.height - r_refdef.view.y - r_refdef.view.height, r_refdef.view.width, r_refdef.view.height, 0, 0, vid_conwidth.integer, vid_conheight.integer, -10, 100, NULL);
R_SetViewport(&viewport);
GL_ColorMask(r_refdef.view.colormask[0], r_refdef.view.colormask[1], r_refdef.view.colormask[2], 1);
- GL_DepthFunc(GL_LEQUAL);
- GL_PolygonOffset(0,0);
- GL_CullFace(GL_NONE);
+ qglDepthFunc(GL_LEQUAL);CHECKGLERROR
+ qglDisable(GL_POLYGON_OFFSET_FILL);CHECKGLERROR
+ GL_CullFace(GL_FRONT); // quake is backwards, this culls back faces
R_EntityMatrix(&identitymatrix);
GL_DepthRange(0, 1);
void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, float red, float green, float blue, float alpha, int flags)
{
- float floats[36];
+ float floats[20];
_DrawQ_SetupAndProcessDrawFlag(flags, pic, alpha);
if(!r_draw2d.integer && !r_draw2d_force)
return;
+ GL_Color(red, green, blue, alpha);
+ R_Mesh_VertexPointer(floats, 0, 0);
+ R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
- floats[12] = 0.0f;floats[13] = 0.0f;
- floats[14] = 1.0f;floats[15] = 0.0f;
- floats[16] = 1.0f;floats[17] = 1.0f;
- floats[18] = 0.0f;floats[19] = 1.0f;
- floats[20] = floats[24] = floats[28] = floats[32] = red;
- floats[21] = floats[25] = floats[29] = floats[33] = green;
- floats[22] = floats[26] = floats[30] = floats[34] = blue;
- floats[23] = floats[27] = floats[31] = floats[35] = alpha;
if (pic)
{
if (width == 0)
if (height == 0)
height = pic->height;
R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
-
-#if 0
+ R_Mesh_TexCoordPointer(0, 2, floats + 12, 0, 0);
+
+#if 1
+ floats[12] = 0.0f;floats[13] = 0.0f;
+ floats[14] = 1.0f;floats[15] = 0.0f;
+ floats[16] = 1.0f;floats[17] = 1.0f;
+ floats[18] = 0.0f;floats[19] = 1.0f;
+#else
// AK07: lets be texel correct on the corners
{
float horz_offset = 0.5f / pic->width;
floats[3] = floats[6] = x + width;
floats[7] = floats[10] = y + height;
- R_Mesh_PrepareVertices_Generic_Arrays(4, floats, floats + 20, floats + 12);
- R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+ R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
}
void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height, float org_x, float org_y, float angle, float red, float green, float blue, float alpha, int flags)
{
- float floats[36];
+ float floats[20];
float af = DEG2RAD(-angle); // forward
float ar = DEG2RAD(-angle + 90); // right
float sinaf = sin(af);
_DrawQ_SetupAndProcessDrawFlag(flags, pic, alpha);
if(!r_draw2d.integer && !r_draw2d_force)
return;
+ GL_Color(red, green, blue, alpha);
+ R_Mesh_VertexPointer(floats, 0, 0);
+ R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
if (pic)
{
if (height == 0)
height = pic->height;
R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
+ R_Mesh_TexCoordPointer(0, 2, floats + 12, 0, 0);
+
+ floats[12] = 0.0f;floats[13] = 0.0f;
+ floats[14] = 1.0f;floats[15] = 0.0f;
+ floats[16] = 1.0f;floats[17] = 1.0f;
+ floats[18] = 0.0f;floats[19] = 1.0f;
}
else
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
floats[9] = x - cosaf*org_x + cosar*(height-org_y);
floats[10] = y - sinaf*org_x + sinar*(height-org_y);
- floats[12] = 0.0f;floats[13] = 0.0f;
- floats[14] = 1.0f;floats[15] = 0.0f;
- floats[16] = 1.0f;floats[17] = 1.0f;
- floats[18] = 0.0f;floats[19] = 1.0f;
- floats[20] = floats[24] = floats[28] = floats[32] = red;
- floats[21] = floats[25] = floats[29] = floats[33] = green;
- floats[22] = floats[26] = floats[30] = floats[34] = blue;
- floats[23] = floats[27] = floats[31] = floats[35] = alpha;
-
- R_Mesh_PrepareVertices_Generic_Arrays(4, floats, floats + 20, floats + 12);
- R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+ R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
}
void DrawQ_Fill(float x, float y, float width, float height, float red, float green, float blue, float alpha, int flags)
{
- float floats[36];
+ float floats[12];
_DrawQ_SetupAndProcessDrawFlag(flags, NULL, alpha);
if(!r_draw2d.integer && !r_draw2d_force)
return;
+ GL_Color(red, green, blue, alpha);
+ R_Mesh_VertexPointer(floats, 0, 0);
+ R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
floats[1] = floats[4] = y;
floats[3] = floats[6] = x + width;
floats[7] = floats[10] = y + height;
- floats[12] = 0.0f;floats[13] = 0.0f;
- floats[14] = 1.0f;floats[15] = 0.0f;
- floats[16] = 1.0f;floats[17] = 1.0f;
- floats[18] = 0.0f;floats[19] = 1.0f;
- floats[20] = floats[24] = floats[28] = floats[32] = red;
- floats[21] = floats[25] = floats[29] = floats[33] = green;
- floats[22] = floats[26] = floats[30] = floats[34] = blue;
- floats[23] = floats[27] = floats[31] = floats[35] = alpha;
-
- R_Mesh_PrepareVertices_Generic_Arrays(4, floats, floats + 20, floats + 12);
- R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+
+ R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
}
/// color tag printing
if(!r_draw2d.integer && !r_draw2d_force)
return startx + DrawQ_TextWidth_UntilWidth_TrackColors_Scale(text, &maxlen, w, h, sw, sh, NULL, ignorecolorcodes, fnt, 1000000000);
+ R_Mesh_ColorPointer(color4f, 0, 0);
R_Mesh_ResetTextureState();
if (!fontmap)
R_Mesh_TexBind(0, fnt->tex);
+ R_Mesh_TexCoordPointer(0, 2, texcoord2f, 0, 0);
+ R_Mesh_VertexPointer(vertex3f, 0, 0);
R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1);
ac = color4f;
}
if (!fontmap || (ch <= 0xFF && fontmap->glyphs[ch].image) || (ch >= 0xE000 && ch <= 0xE0FF))
{
- if (ch > 0xE000)
+ if (ch >= 0xE000)
ch -= 0xE000;
if (ch > 0xFF)
- continue;
+ goto out;
if (fontmap)
{
if (map != ft2_oldstyle_map)
if (batchcount)
{
// switching from freetype to non-freetype rendering
- R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
- R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
batchcount++;
if (batchcount >= QUADELEMENTS_MAXQUADS)
{
- R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
- R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
if (batchcount)
{
// we need a different character map, render what we currently have:
- R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
- R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
batchcount++;
if (batchcount >= QUADELEMENTS_MAXQUADS)
{
- R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
- R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
batchcount = 0;
ac = color4f;
at = texcoord2f;
//prevmap = map;
prevch = ch;
}
+out:
if (shadow)
{
x -= 1.0/pix_x * r_textshadow.value;
}
}
if (batchcount > 0)
- {
- R_Mesh_PrepareVertices_Generic_Arrays(batchcount * 4, vertex3f, color4f, texcoord2f);
- R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, NULL, 0, quadelement3s, NULL, 0);
- }
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, quadelement3i, quadelement3s, 0, 0);
if (outcolor)
*outcolor = colorindex;
if(!r_draw2d.integer && !r_draw2d_force)
return;
+ R_Mesh_VertexPointer(floats, 0, 0);
+ R_Mesh_ColorPointer(floats + 20, 0, 0);
R_Mesh_ResetTextureState();
if (pic)
{
if (height == 0)
height = pic->height;
R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
+ R_Mesh_TexCoordPointer(0, 2, floats + 12, 0, 0);
+ floats[12] = s1;floats[13] = t1;
+ floats[14] = s2;floats[15] = t2;
+ floats[16] = s4;floats[17] = t4;
+ floats[18] = s3;floats[19] = t3;
}
else
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
floats[1] = floats[4] = y;
floats[3] = floats[6] = x + width;
floats[7] = floats[10] = y + height;
- floats[12] = s1;floats[13] = t1;
- floats[14] = s2;floats[15] = t2;
- floats[16] = s4;floats[17] = t4;
- floats[18] = s3;floats[19] = t3;
floats[20] = r1;floats[21] = g1;floats[22] = b1;floats[23] = a1;
floats[24] = r2;floats[25] = g2;floats[26] = b2;floats[27] = a2;
floats[28] = r4;floats[29] = g4;floats[30] = b4;floats[31] = a4;
floats[32] = r3;floats[33] = g3;floats[34] = b3;floats[35] = a3;
- R_Mesh_PrepareVertices_Generic_Arrays(4, floats, floats + 20, floats + 12);
- R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+ R_Mesh_Draw(0, 4, 0, 2, polygonelement3i, polygonelement3s, 0, 0);
}
void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags, qboolean hasalpha)
return;
DrawQ_ProcessDrawFlag(flags, hasalpha);
+ R_Mesh_VertexPointer(mesh->data_vertex3f, 0, 0);
+ R_Mesh_ColorPointer(mesh->data_color4f, 0, 0);
R_Mesh_ResetTextureState();
+ R_Mesh_TexCoordPointer(0, 2, mesh->data_texcoord2f, 0, 0);
R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1);
- R_Mesh_PrepareVertices_Generic_Arrays(mesh->num_vertices, mesh->data_vertex3f, mesh->data_color4f, mesh->data_texcoord2f);
- R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, mesh->data_element3i, NULL, 0, mesh->data_element3s, NULL, 0);
+ R_Mesh_Draw(0, mesh->num_vertices, 0, mesh->num_triangles, mesh->data_element3i, mesh->data_element3s, 0, 0);
}
void DrawQ_LineLoop (drawqueuemesh_t *mesh, int flags)
return;
GL_Color(1,1,1,1);
- switch(vid.renderpath)
+ CHECKGLERROR
+ qglBegin(GL_LINE_LOOP);
+ for (num = 0;num < mesh->num_vertices;num++)
{
- case RENDERPATH_GL11:
- case RENDERPATH_GL13:
- case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
- CHECKGLERROR
- qglBegin(GL_LINE_LOOP);
- for (num = 0;num < mesh->num_vertices;num++)
- {
- if (mesh->data_color4f)
- GL_Color(mesh->data_color4f[num*4+0], mesh->data_color4f[num*4+1], mesh->data_color4f[num*4+2], mesh->data_color4f[num*4+3]);
- qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
- }
- qglEnd();
- CHECKGLERROR
- break;
- case RENDERPATH_D3D9:
- //Con_DPrintf("FIXME D3D9 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
- case RENDERPATH_D3D10:
- Con_DPrintf("FIXME D3D10 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
- case RENDERPATH_D3D11:
- Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
+ if (mesh->data_color4f)
+ GL_Color(mesh->data_color4f[num*4+0], mesh->data_color4f[num*4+1], mesh->data_color4f[num*4+2], mesh->data_color4f[num*4+3]);
+ qglVertex2f(mesh->data_vertex3f[num*3+0], mesh->data_vertex3f[num*3+1]);
}
+ qglEnd();
+ CHECKGLERROR
}
//[515]: this is old, delete
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
- switch(vid.renderpath)
- {
- case RENDERPATH_GL11:
- case RENDERPATH_GL13:
- case RENDERPATH_GL20:
- case RENDERPATH_CGGL:
- CHECKGLERROR
-
- //qglLineWidth(width);CHECKGLERROR
+ CHECKGLERROR
+ //qglLineWidth(width);CHECKGLERROR
- GL_Color(r,g,b,alpha);
- CHECKGLERROR
- qglBegin(GL_LINES);
- qglVertex2f(x1, y1);
- qglVertex2f(x2, y2);
- qglEnd();
- CHECKGLERROR
- break;
- case RENDERPATH_D3D9:
- //Con_DPrintf("FIXME D3D9 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
- case RENDERPATH_D3D10:
- Con_DPrintf("FIXME D3D10 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
- case RENDERPATH_D3D11:
- Con_DPrintf("FIXME D3D11 %s:%i %s\n", __FILE__, __LINE__, __FUNCTION__);
- break;
- }
+ GL_Color(r,g,b,alpha);
+ CHECKGLERROR
+ qglBegin(GL_LINES);
+ qglVertex2f(x1, y1);
+ qglVertex2f(x2, y2);
+ qglEnd();
+ CHECKGLERROR
}
void DrawQ_SetClipArea(float x, float y, float width, float height)
{
case RENDERPATH_GL20:
case RENDERPATH_CGGL:
- case RENDERPATH_D3D9:
- case RENDERPATH_D3D10:
- case RENDERPATH_D3D11:
if (vid_usinghwgamma || v_glslgamma.integer)
return;
break;
break;
}
// all the blends ignore depth
+ R_Mesh_VertexPointer(blendvertex3f, 0, 0);
+ R_Mesh_ColorPointer(NULL, 0, 0);
R_Mesh_ResetTextureState();
R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
GL_DepthMask(true);
GL_BlendFunc(GL_DST_COLOR, GL_ONE);
while (c[0] >= 1.01f || c[1] >= 1.01f || c[2] >= 1.01f)
{
- GL_Color(c[0] - 1, c[1] - 1, c[2] - 1, 1);
- R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
- R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+ GL_Color(bound(0, c[0] - 1, 1), bound(0, c[1] - 1, 1), bound(0, c[2] - 1, 1), 1);
+ R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
VectorScale(c, 0.5, c);
}
}
if (c[0] >= 0.01f || c[1] >= 0.01f || c[2] >= 0.01f)
{
GL_BlendFunc(GL_ONE, GL_ONE);
- GL_Color(c[0] - 1, c[1] - 1, c[2] - 1, 1);
- R_Mesh_PrepareVertices_Generic_Arrays(3, blendvertex3f, NULL, NULL);
- R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, NULL, 0, polygonelement3s, NULL, 0);
+ GL_Color(c[0], c[1], c[2], 1);
+ R_Mesh_Draw(0, 3, 0, 1, polygonelement3i, polygonelement3s, 0, 0);
}
}