1 #include "gl.h"
2 #include "state.h"
3 
4 #ifndef GL_STACK_H
5 #define GL_STACK_H
6 
7 #define STACK_SIZE 16
8 
9 typedef struct {
10     GLbitfield mask;
11 
12     // GL_COLOR_BUFFER_BIT
13     GLboolean alpha_test;
14     GLint alpha_test_func;
15     GLclampf alpha_test_ref;
16 
17     GLboolean blend;
18     GLint blend_src_func;
19     GLint blend_dst_func;
20 
21     GLboolean dither;
22 
23     GLboolean color_logic_op;
24     GLint logic_op;
25 
26     GLfloat clear_color[4];
27     GLfloat color_mask[4];
28 
29     // GL_CURRENT_BIT
30     GLfloat color[4];
31     GLfloat normal[4];
32     GLfloat tex[4];
33 
34     // TODO: can only fill this via raster.c
35     GLfloat raster_pos[3];
36     GLboolean raster_valid;
37 
38     // GL_DEPTH_BUFFER_BIT
39     GLboolean depth_test;
40     GLint depth_func;
41     GLfloat clear_depth;
42     GLint depth_mask;
43 
44     // GL_ENABLE_BIT
45     GLboolean cull_face;
46     GLboolean normalize;
47     GLboolean polygon_offset_fill;
48     GLboolean stencil_test;
49     GLboolean texture_2d;
50 
51     // GL_FOG_BIT
52     GLboolean fog;
53     GLfloat fog_color[4];
54     GLfloat fog_density;
55     GLfloat fog_start;
56     GLfloat fog_end;
57     GLint fog_mode;
58 
59     // GL_HINT_BIT
60     GLint perspective_hint;
61     GLint point_smooth_hint;
62     GLint line_smooth_hint;
63     GLint fog_hint;
64     GLint mipmap_hint;
65 
66     // GL_LIGHTING_BIT
67     GLboolean lighting;
68     GLboolean *lights_enabled;
69     GLfloat *lights;
70     GLint light_model_ambient[4];
71     GLint light_model_two_side;
72     GLint shade_model;
73 
74     // GL_LINE_BIT
75     GLboolean line_smooth;
76     GLboolean line_stipple; // TODO: needs to be hooked locally?
77     GLfloat line_width;
78 
79     // GL_LIST_BIT
80     GLint list_base;
81 
82     // GL_MULTISAMPLE_BIT
83     GLboolean multisample;
84     GLboolean sample_alpha_to_coverage;
85     GLboolean sample_alpha_to_one;
86     GLboolean sample_coverage;
87 
88     // GL_POINT_BIT
89     GLboolean point_smooth;
90     GLfloat point_size;
91 
92     // TODO: GL_POLYGON_BIT
93     // TODO: GL_POLYGON_STIPPLE_BIT
94 
95     // GL_SCISSOR_BIT
96     GLboolean scissor_test;
97     GLfloat scissor_box[4];
98 
99     // TODO: GL_STENCIL_BUFFER_BIT
100 
101     // GL_TEXTURE_BIT
102     GLint texture;
103 
104     // TODO: GL_TRANSFORM_BIT
105     // TODO: GL_VIEWPORT_BIT
106 
107     // dynamically-sized shenanigans
108     GLboolean *clip_planes_enabled;
109     GLfloat *clip_planes;
110 
111     // misc
112     unsigned int len;
113     unsigned int cap;
114 } glstack_t;
115 
116 typedef struct {
117     GLbitfield mask;
118 
119     // GL_CLIENT_PIXEL_STORE_BIT
120     GLint pack_align;
121     GLint unpack_align;
122     GLuint unpack_row_length;
123     GLuint unpack_skip_pixels;
124     GLuint unpack_skip_rows;
125 
126     // GL_CLIENT_VERTEX_ARRAY_BIT
127     GLboolean vert_enable;
128     GLboolean color_enable;
129     GLboolean tex_enable;
130     GLboolean normal_enable;
131     pointer_state_t verts;
132     pointer_state_t color;
133     pointer_state_t normal;
134     pointer_state_t tex;
135 
136     unsigned int len;
137     unsigned int cap;
138 } glclientstack_t;
139 
140 void glPushClientAttrib(GLbitfield mask);
141 void glPopClientAttrib();
142 void glPushAttrib(GLbitfield mask);
143 void glPopAttrib();
144 
145 #endif
146