]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_draw.c
rewrote RecursiveHullCheck, no longer gets stuck on angle changes, and is generally...
[xonotic/darkplaces.git] / gl_draw.c
index 59ed467ea1ce82fe682c46f7ff38d70cb4f86c79..bf3de8f98252d974c1098baaca33aa57e3aa9236 100644 (file)
--- a/gl_draw.c
+++ b/gl_draw.c
@@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
 //#define GL_COLOR_INDEX8_EXT     0x80E5
 
-cvar_t         scr_conalpha = {"scr_conalpha", "1"};
+cvar_t         scr_conalpha = {CVAR_SAVE, "scr_conalpha", "1"};
 
 byte           *draw_chars;                            // 8*8 graphic characters
 qpic_t         *draw_disc;
@@ -154,7 +154,7 @@ void gl_draw_newmap(void)
 {
 }
 
-char engineversion[40];
+extern char engineversion[40];
 int engineversionx, engineversiony;
 
 extern void R_Textures_Init();
@@ -163,19 +163,10 @@ void GL_Draw_Init (void)
        int i;
        Cvar_RegisterVariable (&scr_conalpha);
 
-       Cmd_AddCommand ("loadsky", &LoadSky_f);
-
-#if defined(__linux__)
-       sprintf (engineversion, "DarkPlaces Linux   GL %.2f build %3i", (float) VERSION, buildnumber);
-#elif defined(WIN32)
-       sprintf (engineversion, "DarkPlaces Windows GL %.2f build %3i", (float) VERSION, buildnumber);
-#else
-       sprintf (engineversion, "DarkPlaces Unknown GL %.2f build %3i", (float) VERSION, buildnumber);
-#endif
        for (i = 0;i < 40 && engineversion[i];i++)
                engineversion[i] += 0x80; // shift to orange
-       engineversionx = vid.width - strlen(engineversion) * 8 - 8;
-       engineversiony = vid.height - 8;
+       engineversionx = vid.conwidth - strlen(engineversion) * 8 - 8;
+       engineversiony = vid.conheight - 8;
 
        R_Textures_Init();
        R_RegisterModule("GL_Draw", gl_draw_start, gl_draw_shutdown, gl_draw_newmap);
@@ -214,7 +205,7 @@ void Draw_Character (int x, int y, int num)
                return;
        glBindTexture(GL_TEXTURE_2D, R_GetTexture(char_texture));
        // LordHavoc: NEAREST mode on text if not scaling up
-       if (glwidth <= (int) vid.width)
+       if (vid.realwidth <= (int) vid.conwidth)
        {
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -241,7 +232,7 @@ void Draw_Character (int x, int y, int num)
        glEnd ();
 
        // LordHavoc: revert to LINEAR mode
-//     if (glwidth < (int) vid.width)
+//     if (vid.realwidth <= (int) vid.conwidth)
 //     {
 //             glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 //             glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@@ -260,7 +251,7 @@ void Draw_String (int x, int y, char *str, int maxlen)
        float frow, fcol;
        if (!r_render.value)
                return;
-       if (y <= -8 || y >= (int) vid.height || x >= (int) vid.width || *str == 0) // completely offscreen or no text to print
+       if (y <= -8 || y >= (int) vid.conheight || x >= (int) vid.conwidth || *str == 0) // completely offscreen or no text to print
                return;
        if (maxlen < 1)
                maxlen = strlen(str);
@@ -269,7 +260,7 @@ void Draw_String (int x, int y, char *str, int maxlen)
        glBindTexture(GL_TEXTURE_2D, R_GetTexture(char_texture));
 
        // LordHavoc: NEAREST mode on text if not scaling up
-       if (glwidth <= (int) vid.width)
+       if (vid.realwidth <= (int) vid.conwidth)
        {
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
                glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
@@ -285,7 +276,7 @@ void Draw_String (int x, int y, char *str, int maxlen)
        else
                glColor3f(1.0f,1.0f,1.0f);
        glBegin (GL_QUADS);
-       while (maxlen-- && x < (int) vid.width) // stop rendering when out of characters or room
+       while (maxlen-- && x < (int) vid.conwidth) // stop rendering when out of characters or room
        {
                if ((num = *str++) != 32) // skip spaces
                {
@@ -301,13 +292,22 @@ void Draw_String (int x, int y, char *str, int maxlen)
        glEnd ();
 
        // LordHavoc: revert to LINEAR mode
-//     if (glwidth < (int) vid.width)
+//     if (vid.realwidth < (int) vid.conwidth)
 //     {
 //             glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 //             glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 //     }
 }
 
+void Draw_AdditiveString (int x, int y, char *str, int maxlen)
+{
+       if (!r_render.value)
+               return;
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+       Draw_String(x, y, str, maxlen);
+       glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+}
+
 void Draw_GenericPic (rtexture_t *tex, float red, float green, float blue, float alpha, int x, int y, int width, int height)
 {
        if (!r_render.value)
@@ -332,7 +332,8 @@ Draw_AlphaPic
 */
 void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
 {
-       Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,alpha, x,y,pic->width, pic->height);
+       if (pic)
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,alpha, x,y,pic->width, pic->height);
 }
 
 
@@ -343,7 +344,19 @@ Draw_Pic
 */
 void Draw_Pic (int x, int y, qpic_t *pic)
 {
-       Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+       if (pic)
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+}
+
+
+void Draw_AdditivePic (int x, int y, qpic_t *pic)
+{
+       if (pic)
+       {
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE);
+               Draw_GenericPic(((glpic_t *)pic->data)->tex, 1,1,1,1, x,y,pic->width, pic->height);
+               glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+       }
 }
 
 
@@ -360,6 +373,9 @@ void Draw_PicTranslate (int x, int y, qpic_t *pic, byte *translation)
        byte                    *trans, *src, *dest;
        rtexture_t              *rt;
 
+       if (pic == NULL)
+               return;
+
        c = pic->width * pic->height;
        src = menuplyr_pixels;
        dest = trans = qmalloc(c);
@@ -383,9 +399,9 @@ Draw_ConsoleBackground
 */
 void Draw_ConsoleBackground (int lines)
 {
-       Draw_GenericPic (conbacktex, 1,1,1,scr_conalpha.value*lines/vid.height, 0, lines - vid.height, vid.width, vid.height);
+       Draw_GenericPic (conbacktex, 1,1,1,scr_conalpha.value * lines / vid.conheight, 0, lines - vid.conheight, vid.conwidth, vid.conheight);
        // LordHavoc: draw version
-       Draw_String(engineversionx, lines - vid.height + engineversiony, engineversion, 9999);
+       Draw_String(engineversionx, lines - vid.conheight + engineversiony, engineversion, 9999);
 }
 
 /*
@@ -434,11 +450,11 @@ void GL_Set2D (void)
 {
        if (!r_render.value)
                return;
-       glViewport (glx, gly, glwidth, glheight);
+       glViewport (vid.realx, vid.realy, vid.realwidth, vid.realheight);
 
        glMatrixMode(GL_PROJECTION);
     glLoadIdentity ();
-       glOrtho  (0, vid.width, vid.height, 0, -99999, 99999);
+       glOrtho  (0, vid.conwidth, vid.conheight, 0, -99999, 99999);
 
        glMatrixMode(GL_MODELVIEW);
     glLoadIdentity ();
@@ -489,7 +505,7 @@ void SHOWLMP_decodeshow(void)
        float x, y;
        strcpy(lmplabel,MSG_ReadString());
        strcpy(picname, MSG_ReadString());
-       if (nehahra) // LordHavoc: nasty old legacy junk
+       if (gamemode == GAME_NEHAHRA) // LordHavoc: nasty old legacy junk
        {
                x = MSG_ReadByte();
                y = MSG_ReadByte();