mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-08-29 10:13:03 +02:00
174 lines
6.8 KiB
Diff
174 lines
6.8 KiB
Diff
# Renames all the GL_MAX_* macros defined by PortableGL to PGL_MAX_* to avoid conflicts with the Khronos OpenGL headers.
|
|
|
|
--- a/portablegl.h
|
|
+++ b/portablegl.h
|
|
@@ -2450,7 +2450,7 @@ enum
|
|
#define GL_FALSE 0
|
|
#define GL_TRUE 1
|
|
|
|
-#define GL_STENCIL_BITS 8
|
|
+#define PGL_STENCIL_BITS 8
|
|
|
|
// Just GL_STENCIL_BITS of 1's, not an official GL enum/value
|
|
//#define PGL_STENCIL_MASK ((1 << GL_STENCIL_BITS)-1)
|
|
@@ -2460,10 +2460,10 @@ enum
|
|
|
|
// Feel free to change these
|
|
#define PGL_MAX_VERTICES 500000
|
|
-#define GL_MAX_VERTEX_ATTRIBS 8
|
|
-#define GL_MAX_VERTEX_OUTPUT_COMPONENTS (4*GL_MAX_VERTEX_ATTRIBS)
|
|
-#define GL_MAX_DRAW_BUFFERS 4
|
|
-#define GL_MAX_COLOR_ATTACHMENTS 4
|
|
+#define PGL_MAX_VERTEX_ATTRIBS 8
|
|
+#define PGL_MAX_VERTEX_OUTPUT_COMPONENTS (4*PGL_MAX_VERTEX_ATTRIBS)
|
|
+#define PGL_MAX_DRAW_BUFFERS 4
|
|
+#define PGL_MAX_COLOR_ATTACHMENTS 4
|
|
|
|
//TODO use prefix like GL_SMOOTH? PGL_SMOOTH?
|
|
enum { PGL_SMOOTH, PGL_FLAT, PGL_NOPERSPECTIVE };
|
|
@@ -2522,7 +2522,7 @@ typedef struct glProgram
|
|
frag_func fragment_shader;
|
|
void* uniform;
|
|
GLsizei vs_output_size;
|
|
- GLenum interpolation[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ GLenum interpolation[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
|
|
GLboolean fragdepth_or_discard;
|
|
|
|
@@ -2571,7 +2571,7 @@ void init_glVertex_Attrib(glVertex_Attrib* v);
|
|
|
|
typedef struct glVertex_Array
|
|
{
|
|
- glVertex_Attrib vertex_attribs[GL_MAX_VERTEX_ATTRIBS];
|
|
+ glVertex_Attrib vertex_attribs[PGL_MAX_VERTEX_ATTRIBS];
|
|
|
|
//GLuint n_array_bufs;
|
|
GLuint element_buffer;
|
|
@@ -2893,10 +2893,10 @@ typedef struct glContext
|
|
// TODO make some or all of these locals, measure performance
|
|
// impact. Would be necessary in the long term if I ever
|
|
// parallelize more
|
|
- vec4 vertex_attribs_vs[GL_MAX_VERTEX_ATTRIBS];
|
|
+ vec4 vertex_attribs_vs[PGL_MAX_VERTEX_ATTRIBS];
|
|
Shader_Builtins builtins;
|
|
Vertex_Shader_output vs_output;
|
|
- float fs_input[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float fs_input[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
|
|
GLboolean depth_test;
|
|
GLboolean line_smooth;
|
|
@@ -3032,7 +3032,7 @@ typedef struct pgl_prog_info
|
|
vert_func vs;
|
|
frag_func fs;
|
|
int vs_out_sz;
|
|
- GLenum interp[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ GLenum interp[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
GLboolean uses_fragdepth_or_discard;
|
|
} pgl_prog_info;
|
|
|
|
@@ -5924,8 +5924,8 @@ static void vertex_stage(const GLvoid* indices, GLsizei count, GLsizei instance_
|
|
//also initialize the vertex_attrib space
|
|
// TODO does creating enabled array actually help perf? At what number
|
|
// of GL_MAX_VERTEX_ATTRIBS and vertices does it become a benefit?
|
|
- int enabled[GL_MAX_VERTEX_ATTRIBS] = { 0 };
|
|
- for (i=0, j=0; i<GL_MAX_VERTEX_ATTRIBS; ++i) {
|
|
+ int enabled[PGL_MAX_VERTEX_ATTRIBS] = { 0 };
|
|
+ for (i=0, j=0; i<PGL_MAX_VERTEX_ATTRIBS; ++i) {
|
|
if (v[i].enabled) {
|
|
if (v[i].divisor == 0) {
|
|
enabled[j++] = i;
|
|
@@ -5979,7 +5979,7 @@ static void vertex_stage(const GLvoid* indices, GLsizei count, GLsizei instance_
|
|
//TODO make fs_input static? or a member of glContext?
|
|
static void draw_point(glVertex* vert, float poly_offset)
|
|
{
|
|
- float fs_input[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float fs_input[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
|
|
vec3 point = vec4_to_vec3h(vert->screen_space);
|
|
point.z += poly_offset; // couldn't this put it outside of [-1,1]?
|
|
@@ -6203,8 +6203,8 @@ static void draw_line_clip(glVertex* v1, glVertex* v2)
|
|
p1 = v1->clip_space;
|
|
p2 = v2->clip_space;
|
|
|
|
- float v1_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
- float v2_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float v1_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float v2_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
|
|
vec3 hp1, hp2;
|
|
|
|
@@ -6901,8 +6901,8 @@ static void draw_triangle_clip(glVertex* v0, glVertex* v1, glVertex* v2, unsigne
|
|
float tt;
|
|
|
|
//quite a bit of stack if there's a lot of clipping ...
|
|
- float tmp1_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
- float tmp2_out[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float tmp1_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float tmp2_out[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
|
|
tmp1.vs_out = tmp1_out;
|
|
tmp2.vs_out = tmp2_out;
|
|
@@ -7136,14 +7136,14 @@ static void draw_triangle_fill(glVertex* v0, glVertex* v1, glVertex* v2, unsigne
|
|
Line l20 = make_Line(hp2.x, hp2.y, hp0.x, hp0.y);
|
|
|
|
float alpha, beta, gamma, tmp, tmp2, z;
|
|
- float fs_input[GL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
- float perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS*3];
|
|
+ float fs_input[PGL_MAX_VERTEX_OUTPUT_COMPONENTS];
|
|
+ float perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS*3];
|
|
float* vs_output = &c->vs_output.output_buf.a[0];
|
|
|
|
for (int i=0; i<c->vs_output.size; ++i) {
|
|
perspective[i] = v0->vs_out[i]/p0.w;
|
|
- perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v1->vs_out[i]/p1.w;
|
|
- perspective[2*GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v2->vs_out[i]/p2.w;
|
|
+ perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v1->vs_out[i]/p1.w;
|
|
+ perspective[2*PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] = v2->vs_out[i]/p2.w;
|
|
}
|
|
float inv_w0 = 1/p0.w; //is this worth it? faster than just dividing by w down below?
|
|
float inv_w1 = 1/p1.w;
|
|
@@ -7190,7 +7190,7 @@ static void draw_triangle_fill(glVertex* v0, glVertex* v1, glVertex* v2, unsigne
|
|
|
|
for (int i=0; i<c->vs_output.size; ++i) {
|
|
if (c->vs_output.interpolation[i] == PGL_SMOOTH) {
|
|
- tmp = alpha*perspective[i] + beta*perspective[GL_MAX_VERTEX_OUTPUT_COMPONENTS + i] + gamma*perspective[2*GL_MAX_VERTEX_OUTPUT_COMPONENTS + i];
|
|
+ tmp = alpha*perspective[i] + beta*perspective[PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i] + gamma*perspective[2*PGL_MAX_VERTEX_OUTPUT_COMPONENTS + i];
|
|
|
|
fs_input[i] = tmp/tmp2;
|
|
|
|
@@ -7705,7 +7705,7 @@ void default_fs(float* fs_input, Shader_Builtins* builtins, void* uniforms)
|
|
void init_glVertex_Array(glVertex_Array* v)
|
|
{
|
|
v->deleted = GL_FALSE;
|
|
- for (int i=0; i<GL_MAX_VERTEX_ATTRIBS; ++i)
|
|
+ for (int i=0; i<PGL_MAX_VERTEX_ATTRIBS; ++i)
|
|
init_glVertex_Attrib(&v->vertex_attribs[i]);
|
|
}
|
|
|
|
@@ -8937,7 +8937,7 @@ void glVertexAttribPointer(GLuint index, GLint size, GLenum type, GLboolean norm
|
|
// but you can easily remove c->cur_vertex_array from the check
|
|
// below to enable client arrays for all VAOs and it will
|
|
// still work just fine
|
|
- if (index >= GL_MAX_VERTEX_ATTRIBS || size < 1 || size > 4 ||
|
|
+ if (index >= PGL_MAX_VERTEX_ATTRIBS || size < 1 || size > 4 ||
|
|
(c->cur_vertex_array && !c->bound_buffers[GL_ARRAY_BUFFER-GL_ARRAY_BUFFER] && pointer)) {
|
|
if (!c->error)
|
|
c->error = GL_INVALID_OPERATION;
|
|
@@ -8990,7 +8990,7 @@ void glDisableVertexAttribArray(GLuint index)
|
|
|
|
void glVertexAttribDivisor(GLuint index, GLuint divisor)
|
|
{
|
|
- if (index >= GL_MAX_VERTEX_ATTRIBS) {
|
|
+ if (index >= PGL_MAX_VERTEX_ATTRIBS) {
|
|
if (!c->error)
|
|
c->error = GL_INVALID_VALUE;
|
|
return;
|
|
@@ -9694,7 +9694,7 @@ GLuint pglCreateProgram(vert_func vertex_shader, frag_func fragment_shader, GLsi
|
|
return 0;
|
|
}
|
|
|
|
- if (n < 0 || n > GL_MAX_VERTEX_OUTPUT_COMPONENTS) {
|
|
+ if (n < 0 || n > PGL_MAX_VERTEX_OUTPUT_COMPONENTS) {
|
|
if (!c->error)
|
|
c->error = GL_INVALID_VALUE;
|
|
return 0;
|