]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
theora encoding: allow both bitrate and quality to be -1 for insane quality
[xonotic/darkplaces.git] / gl_draw.c
index 2e1ce7a65d3c1779cbf2a1ca0c0d5e0547cf35a7..705253b00a30810808935160790f2fd6ff89082d 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -404,7 +404,7 @@ reload:
                pic->height = image_height;
                if (!pic->autoload)
                {
-                       pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, image_width, image_height, pixels, r_texture_sRGB_2d.integer ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, pic->texflags & (pic->hasalpha ? ~0 : ~TEXF_ALPHA), -1, NULL);
+                       pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, image_width, image_height, pixels, vid.sRGB2D ? TEXTYPE_SRGB_BGRA : TEXTYPE_BGRA, pic->texflags & (pic->hasalpha ? ~0 : ~TEXF_ALPHA), -1, NULL);
                        if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
                                R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
                }
@@ -431,8 +431,11 @@ reload:
                        pic->width = lmpdata[0] + lmpdata[1] * 256 + lmpdata[2] * 65536 + lmpdata[3] * 16777216;
                        pic->height = lmpdata[4] + lmpdata[5] * 256 + lmpdata[6] * 65536 + lmpdata[7] * 16777216;
                        // if no high quality replacement image was found, upload the original low quality texture
-                       if (!pixels)
-                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+                       if (!loaded)
+                       {
+                               loaded = true;
+                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, vid.sRGB2D ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+                       }
                }
                Mem_Free(lmpdata);
        }
@@ -447,16 +450,22 @@ reload:
                        pic->width = 128;
                        pic->height = 128;
                        // if no high quality replacement image was found, upload the original low quality texture
-                       if (!pixels)
-                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, 128, 128, lmpdata, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_font);
+                       if (!loaded)
+                       {
+                               loaded = true;
+                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, 128, 128, lmpdata, vid.sRGB2D != 0 ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_font);
+                       }
                }
                else
                {
                        pic->width = lmpdata[0] + lmpdata[1] * 256 + lmpdata[2] * 65536 + lmpdata[3] * 16777216;
                        pic->height = lmpdata[4] + lmpdata[5] * 256 + lmpdata[6] * 65536 + lmpdata[7] * 16777216;
                        // if no high quality replacement image was found, upload the original low quality texture
-                       if (!pixels)
-                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+                       if (!loaded)
+                       {
+                               loaded = true;
+                               pic->tex = R_LoadTexture2D(drawtexturepool, pic->name, pic->width, pic->height, lmpdata + 8, vid.sRGB2D != 0 ? TEXTYPE_SRGB_PALETTE : TEXTYPE_PALETTE, pic->texflags, -1, palette_bgra_transparent);
+                       }
                }
        }
 
@@ -493,13 +502,13 @@ rtexture_t *Draw_GetPicTexture(cachepic_t *pic)
                }
                if (pic->tex == NULL)
                {
-                       pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, r_texture_sRGB_2d.integer != 0);
+                       pic->tex = loadtextureimage(drawtexturepool, pic->name, false, pic->texflags, true, vid.sRGB2D);
                        if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
                                R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
                }
                if (pic->tex == NULL && !strncmp(pic->name, "gfx/", 4))
                {
-                       pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, r_texture_sRGB_2d.integer != 0);
+                       pic->tex = loadtextureimage(drawtexturepool, pic->name+4, false, pic->texflags, true, vid.sRGB2D);
                        if (r_texture_dds_save.integer && qglGetCompressedTexImageARB && pic->tex)
                                R_SaveTextureDDSFile(pic->tex, va("dds/%s.dds", pic->name), r_texture_dds_save.integer < 2, pic->hasalpha);
                }
@@ -1123,7 +1132,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
                        width = pic->width;
                if (height == 0)
                        height = pic->height;
-               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true);
 
 #if 0
       // AK07: lets be texel correct on the corners
@@ -1139,7 +1148,7 @@ void DrawQ_Pic(float x, float y, cachepic_t *pic, float width, float height, flo
 #endif
        }
        else
-               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
        floats[2] = floats[5] = floats[8] = floats[11] = 0;
        floats[0] = floats[9] = x;
@@ -1172,10 +1181,10 @@ void DrawQ_RotPic(float x, float y, cachepic_t *pic, float width, float height,
                        width = pic->width;
                if (height == 0)
                        height = pic->height;
-               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true);
        }
        else
-               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
        floats[2] = floats[5] = floats[8] = floats[11] = 0;
 
@@ -1217,7 +1226,7 @@ void DrawQ_Fill(float x, float y, float width, float height, float red, float gr
                return;
 
 //     R_Mesh_ResetTextureState();
-       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
        floats[2] = floats[5] = floats[8] = floats[11] = 0;
        floats[0] = floats[9] = x;
@@ -1544,7 +1553,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
 //     R_Mesh_ResetTextureState();
        if (!fontmap)
                R_Mesh_TexBind(0, fnt->tex);
-       R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1);
+       R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, true);
 
        ac = color4f;
        at = texcoord2f;
@@ -1680,7 +1689,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
                                                        at = texcoord2f;
                                                        av = vertex3f;
                                                }
-                                               R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1);
+                                               R_SetupShader_Generic(fnt->tex, NULL, GL_MODULATE, 1, true);
                                                map = ft2_oldstyle_map;
                                        }
                                }
@@ -1749,7 +1758,7 @@ float DrawQ_String_Scale(float startx, float starty, const char *text, size_t ma
                                                        break;
                                                }
                                        }
-                                       R_SetupShader_Generic(map->pic->tex, NULL, GL_MODULATE, 1);
+                                       R_SetupShader_Generic(map->pic->tex, NULL, GL_MODULATE, 1, true);
                                }
 
                                mapch = ch - map->start;
@@ -1893,10 +1902,10 @@ void DrawQ_SuperPic(float x, float y, cachepic_t *pic, float width, float height
                        width = pic->width;
                if (height == 0)
                        height = pic->height;
-               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(Draw_GetPicTexture(pic), NULL, GL_MODULATE, 1, true);
        }
        else
-               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
        floats[2] = floats[5] = floats[8] = floats[11] = 0;
        floats[0] = floats[9] = x;
@@ -1925,7 +1934,7 @@ void DrawQ_Mesh (drawqueuemesh_t *mesh, int flags, qboolean hasalpha)
        DrawQ_ProcessDrawFlag(flags, hasalpha);
 
 //     R_Mesh_ResetTextureState();
-       R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1);
+       R_SetupShader_Generic(mesh->texture, NULL, GL_MODULATE, 1, true);
 
        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);
@@ -1982,7 +1991,7 @@ void DrawQ_Line (float width, float x1, float y1, float x2, float y2, float r, f
        if(!r_draw2d.integer && !r_draw2d_force)
                return;
 
-       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
        switch(vid.renderpath)
        {
@@ -2040,7 +2049,7 @@ void DrawQ_Lines (float width, int numlines, const float *vertex3f, const float
        case RENDERPATH_GL20:
                CHECKGLERROR
 
-               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+               R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
 
                //qglLineWidth(width);CHECKGLERROR
 
@@ -2145,7 +2154,7 @@ void R_DrawGamma(void)
        }
        // all the blends ignore depth
 //     R_Mesh_ResetTextureState();
-       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1);
+       R_SetupShader_Generic(NULL, NULL, GL_MODULATE, 1, true);
        GL_DepthMask(true);
        GL_DepthRange(0, 1);
        GL_PolygonOffset(0, 0);