forked from jsgf/pspgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glGetIntegerv.c
98 lines (92 loc) · 2.53 KB
/
glGetIntegerv.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "pspgl_internal.h"
#define GU_PSM_5650 (0) /* Display, Texture, Palette */
#define GU_PSM_5551 (1) /* Display, Texture, Palette */
#define GU_PSM_4444 (2) /* Display, Texture, Palette */
#define GU_PSM_8888 (3) /* Display, Texture, Palette */
static const
struct {
unsigned int red_bits : 4;
unsigned int green_bits : 4;
unsigned int blue_bits : 4;
unsigned int alpha_bits : 4;
} colorfmt [] = {
{ .red_bits = 5, .green_bits = 6, .blue_bits = 5, .alpha_bits = 0 },
{ .red_bits = 5, .green_bits = 5, .blue_bits = 5, .alpha_bits = 1 },
{ .red_bits = 4, .green_bits = 4, .blue_bits = 4, .alpha_bits = 4 },
{ .red_bits = 8, .green_bits = 8, .blue_bits = 8, .alpha_bits = 8 },
};
void glGetIntegerv (GLenum pname, GLint *params)
{
struct pspgl_surface *s = pspgl_curctx->draw;
switch (pname) {
case GL_MAX_TEXTURE_SIZE:
params[0] = 512;
break;
case GL_VIEWPORT:
/* XXX IMPRPOVE: better read from registers / register cache */
params[0] = pspgl_curctx->viewport.x;
params[1] = pspgl_curctx->viewport.y;
params[2] = pspgl_curctx->viewport.width;
params[3] = pspgl_curctx->viewport.height;
break;
case GL_MAX_VIEWPORT_DIMS:
params[0] = s->width;
params[1] = s->height;
break;
case GL_DEPTH_BITS:
params[0] = (s->depth_buffer == NULL) ? 0 : 16;
break;
case GL_STENCIL_BITS:
params[0] = colorfmt[s->pixfmt].alpha_bits;
break;
case GL_RED_BITS:
params[0] = colorfmt[s->pixfmt].red_bits;
break;
case GL_GREEN_BITS:
params[0] = colorfmt[s->pixfmt].green_bits;
break;
case GL_BLUE_BITS:
params[0] = colorfmt[s->pixfmt].blue_bits;
break;
case GL_ALPHA_BITS:
params[0] = colorfmt[s->pixfmt].alpha_bits;
break;
case GL_MAX_TEXTURE_UNITS_ARB:
params[0] = 1;
break;
case GL_MAX_LIGHTS:
params[0] = 4;
break;
case GL_MAX_CLIP_PLANES:
params[0] = 0;
break;
case GL_STENCIL_WRITEMASK:
params[0] = pspgl_curctx->write_mask.stencil;
break;
case GL_DEPTH_CLEAR_VALUE:
params[0] = pspgl_curctx->clear.depth;
break;
case GL_STENCIL_CLEAR_VALUE:
params[0] = pspgl_curctx->clear.stencil;
break;
case GL_MAX_ATTRIB_STACK_DEPTH:
params[0] = MAX_ATTRIB_STACK;
break;
case GL_ATTRIB_STACK_DEPTH:
params[0] = pspgl_curctx->attribstackdepth;
break;
//@@@ added by Edorul for display lists
case GL_LIST_BASE:
params[0] = pspgl_curctx->displaylists.calllists_base;
break;
case GL_LIST_MODE:
params[0] = pspgl_curctx->displaylists.is_in_glNewList;
break;
case GL_LIST_INDEX:
params[0] = pspgl_curctx->displaylists.index;
break;
//@@@ end of addition
default:
GLERROR(GL_INVALID_ENUM);
}
}