Subversion Repositories eduke32

Rev

Rev 870 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
99 terminx 1
#include "compat.h"
2
#include "osd.h"
3
#include "build.h"
4
#include "baselayer.h"
5
 
6
#ifdef RENDERTYPEWIN
7
#include "winlayer.h"
8
#endif
9
 
831 terminx 10
char scantoasc[128] =
11
{
12
    0,0,'1','2','3','4','5','6','7','8','9','0','-','=',0,0,
13
    'q','w','e','r','t','y','u','i','o','p','[',']',0,0,'a','s',
14
    'd','f','g','h','j','k','l',';',39,'`',0,92,'z','x','c','v',
15
    'b','n','m',',','.','/',0,'*',0,32,0,0,0,0,0,0,
16
    0,0,0,0,0,0,0,'7','8','9','-','4','5','6','+','1',
17
    '2','3','0','.',0,0,0,0,0,0,0,0,0,0,0,0,
18
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
19
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
20
};
21
 
99 terminx 22
#ifdef USE_OPENGL
584 terminx 23
struct glinfo glinfo =
24
{
25
    "Unknown",  // vendor
26
    "Unknown",  // renderer
27
    "0.0.0",    // version
28
    "",         // extensions
109 terminx 29
 
584 terminx 30
    1.0,                // max anisotropy
31
    0,          // brga texture format
32
    0,          // clamp-to-edge support
33
    0,          // texture compression
34
    0,          // non-power-of-two textures
35
    0,          // multisampling
36
    0,          // nvidia multisampling hint
37
    0,       // ARBfp
38
    0,       // depth textures
39
    0,       // shadow comparison
40
    0,       // Frame Buffer Objects
41
    0,       // rectangle textures
42
    0,       // multitexturing
43
    0,       // env_combine
44
    0,       // Vertex Buffer Objects
627 terminx 45
    0,       // GL info dumped
584 terminx 46
};
99 terminx 47
#endif
48
 
654 terminx 49
static void onvideomodechange(int newmode) { UNREFERENCED_PARAMETER(newmode); }
99 terminx 50
void (*baselayer_onvideomodechange)(int) = onvideomodechange;
51
 
855 terminx 52
#if defined(POLYMOST)
99 terminx 53
static int osdfunc_setrendermode(const osdfuncparm_t *parm)
54
{
109 terminx 55
    int m;
56
    char *p;
99 terminx 57
 
584 terminx 58
    char *modestrs[] =
59
    {
848 terminx 60
        "classic software", "completely broken polygonal flat-shaded software",
584 terminx 61
        "polygonal textured software", "polygonal OpenGL", "great justice"
62
    };
99 terminx 63
 
109 terminx 64
    if (parm->numparms != 1) return OSDCMD_SHOWHELP;
65
    m = Bstrtol(parm->parms[0], &p, 10);
99 terminx 66
 
278 Plagman 67
    if (m < 0 || m > 4) return OSDCMD_SHOWHELP;
99 terminx 68
 
109 terminx 69
    setrendermode(m);
584 terminx 70
    OSD_Printf("Rendering method changed to %s\n", modestrs[ getrendermode()]);
99 terminx 71
 
109 terminx 72
    return OSDCMD_OK;
99 terminx 73
}
855 terminx 74
#if defined(USE_OPENGL)
99 terminx 75
#ifdef DEBUGGINGAIDS
76
static int osdcmd_hicsetpalettetint(const osdfuncparm_t *parm)
77
{
584 terminx 78
    int pal, cols[3], eff;
109 terminx 79
 
80
    if (parm->numparms != 5) return OSDCMD_SHOWHELP;
81
 
82
    pal = Batol(parm->parms[0]);
83
    cols[0] = Batol(parm->parms[1]);
84
    cols[1] = Batol(parm->parms[2]);
85
    cols[2] = Batol(parm->parms[3]);
86
    eff = Batol(parm->parms[4]);
87
 
88
    hicsetpalettetint(pal,cols[0],cols[1],cols[2],eff);
89
 
90
    return OSDCMD_OK;
99 terminx 91
}
92
#endif
93
 
627 terminx 94
int osdcmd_glinfo(const osdfuncparm_t *parm)
99 terminx 95
{
109 terminx 96
    char *s,*t,*u,i;
99 terminx 97
 
654 terminx 98
    UNREFERENCED_PARAMETER(parm);
99
 
584 terminx 100
    if (bpp == 8)
101
    {
627 terminx 102
        initprintf("glinfo: Not in OpenGL mode.\n");
109 terminx 103
        return OSDCMD_OK;
104
    }
105
 
627 terminx 106
    initprintf("OpenGL Information:\n"
109 terminx 107
               " Version:  %s\n"
108
               " Vendor:   %s\n"
848 terminx 109
               " Renderer: %s\n",
110
               glinfo.version,
111
               glinfo.vendor,
112
               glinfo.renderer);
113
 
114
    if (!glinfo.dumped)
115
        return OSDCMD_OK;
116
 
117
    initprintf(" Maximum anisotropy:      %.1f%s\n"
109 terminx 118
               " BGRA textures:           %s\n"
119
               " Non-x^2 textures:        %s\n"
120
               " Texure compression:      %s\n"
121
               " Clamp-to-edge:           %s\n"
122
               " Multisampling:           %s\n"
123
               " Nvidia multisample hint: %s\n"
446 Plagman 124
               " ARBfp fragment programs: %s\n"
125
               " Depth textures:          %s\n"
126
               " Shadow textures:         %s\n"
127
               " Frame Buffer Objects:    %s\n"
128
               " Rectangle textures:      %s\n"
519 Plagman 129
               " Multitexturing:          %s\n"
130
               " env_combine:             %s\n"
131
               " Vertex Buffer Objects:   %s\n"
109 terminx 132
               " Extensions:\n",
133
               glinfo.maxanisotropy, glinfo.maxanisotropy>1.0?"":" (no anisotropic filtering)",
134
               glinfo.bgra ? "supported": "not supported",
135
               glinfo.texnpot ? "supported": "not supported",
136
               glinfo.texcompr ? "supported": "not supported",
137
               glinfo.clamptoedge ? "supported": "not supported",
138
               glinfo.multisample ? "supported": "not supported",
446 Plagman 139
               glinfo.nvmultisamplehint ? "supported": "not supported",
140
               glinfo.arbfp ? "supported": "not supported",
141
               glinfo.depthtex ? "supported": "not supported",
142
               glinfo.shadow ? "supported": "not supported",
143
               glinfo.fbos ? "supported": "not supported",
519 Plagman 144
               glinfo.rect ? "supported": "not supported",
145
               glinfo.multitex ? "supported": "not supported",
146
               glinfo.envcombine ? "supported": "not supported",
147
               glinfo.vbos ? "supported": "not supported"
109 terminx 148
              );
149
 
150
    s = Bstrdup(glinfo.extensions);
627 terminx 151
    if (!s) initprintf(glinfo.extensions);
584 terminx 152
    else
153
    {
109 terminx 154
        i = 0; t = u = s;
584 terminx 155
        while (*t)
156
        {
157
            if (*t == ' ')
158
            {
159
                if (i&1)
160
                {
109 terminx 161
                    *t = 0;
627 terminx 162
                    initprintf("   %s\n",u);
109 terminx 163
                    u = t+1;
164
                }
165
                i++;
166
            }
167
            t++;
168
        }
627 terminx 169
        if (i&1) initprintf("   %s\n",u);
109 terminx 170
        Bfree(s);
171
    }
172
 
173
    return OSDCMD_OK;
99 terminx 174
}
175
#endif
855 terminx 176
#endif
99 terminx 177
 
178
static int osdcmd_vars(const osdfuncparm_t *parm)
179
{
109 terminx 180
    int showval = (parm->numparms < 1);
181
 
834 terminx 182
    if (!Bstrcasecmp(parm->name, "r_scrcaptureformat"))
584 terminx 183
    {
443 terminx 184
        const char *fmts[] = {"TGA", "PCX"};
834 terminx 185
        if (showval) { OSD_Printf("r_scrcaptureformat is %s\n", fmts[captureformat]); }
584 terminx 186
        else
187
        {
443 terminx 188
            int j;
109 terminx 189
            for (j=0; j<2; j++)
584 terminx 190
                if (!Bstrcasecmp(parm->parms[0], fmts[j])) break;
109 terminx 191
            if (j == 2) return OSDCMD_SHOWHELP;
443 terminx 192
            captureformat = j;
109 terminx 193
        }
194
        return OSDCMD_OK;
195
    }
99 terminx 196
#ifdef SUPERBUILD
832 terminx 197
    else if (!Bstrcasecmp(parm->name, "r_novoxmips"))
584 terminx 198
    {
832 terminx 199
        if (showval) { OSD_Printf("r_novoxmips is %d\n", novoxmips); }
109 terminx 200
        else { novoxmips = (atoi(parm->parms[0]) != 0); }
201
    }
832 terminx 202
    else if (!Bstrcasecmp(parm->name, "r_voxels"))
584 terminx 203
    {
832 terminx 204
        if (showval) { OSD_Printf("r_voxels is %d\n", usevoxels); }
109 terminx 205
        else { usevoxels = (atoi(parm->parms[0]) != 0); }
206
    }
99 terminx 207
#endif
109 terminx 208
    return OSDCMD_SHOWHELP;
99 terminx 209
}
210
 
211
int baselayer_init(void)
212
{
213
#ifdef POLYMOST
109 terminx 214
    OSD_RegisterFunction("setrendermode","setrendermode <number>: sets the engine's rendering mode.\n"
215
                         "Mode numbers are:\n"
216
                         "   0 - Classic Build software\n"
217
                         "   1 - Polygonal flat-shaded software\n"
218
                         "   2 - Polygonal textured software\n"
99 terminx 219
#ifdef USE_OPENGL
109 terminx 220
                         "   3 - Polygonal OpenGL\n"
443 terminx 221
//                         "   4 - great justice renderer\n"
99 terminx 222
#endif
109 terminx 223
                         ,
224
                         osdfunc_setrendermode);
99 terminx 225
#endif
834 terminx 226
    OSD_RegisterFunction("r_scrcaptureformat","r_scrcaptureformat: sets the output format for screenshots (TGA or PCX)",osdcmd_vars);
99 terminx 227
#ifdef SUPERBUILD
832 terminx 228
    OSD_RegisterFunction("r_novoxmips","novoxmips: turn off/on the use of mipmaps when rendering 8-bit voxels",osdcmd_vars);
229
    OSD_RegisterFunction("r_voxels","usevoxels: enable/disable automatic sprite->voxel rendering",osdcmd_vars);
99 terminx 230
#endif
231
#if defined(POLYMOST) && defined(USE_OPENGL)
232
#ifdef DEBUGGINGAIDS
109 terminx 233
    OSD_RegisterFunction("hicsetpalettetint","hicsetpalettetint: sets palette tinting values",osdcmd_hicsetpalettetint);
99 terminx 234
#endif
109 terminx 235
    OSD_RegisterFunction("glinfo","glinfo: shows OpenGL information about the current OpenGL mode",osdcmd_glinfo);
99 terminx 236
#endif
109 terminx 237
    return 0;
99 terminx 238
}
239